Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
factorial ncr
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here /*int t0,t1,t2,t3; int[] t = new int[4]; t[0]=2; t[1]=3; t[2]=5; t[3]=4; for (int i=0; i<t.Length-1; i++){ for (int j=i+1; j<t.Length; j++) { //Console.WriteLine(i + " " + j); if (!t[i].Equals(t[j])){ Console.WriteLine("true"); } else Console.WriteLine("false"); } }*/ Console.WriteLine(nCr(12,8)); /* if(!t0.Equals(t1)) { Console.WriteLine("unique"); */ } public static void Unique(int[] t){ for (int i=0; i<t.Length-1; i++){ for (int j=i+1; j<t.Length; j++) { //Console.WriteLine(i + " " + j); if (!t[i].Equals(t[j])){ Console.WriteLine("true"); } else Console.WriteLine("false"); } } } public static int nCr(int n, int r) { return (Factorial(n)/Factorial(r))/Factorial(n-r); } public static int Factorial(int n) { if (n>0) { for (int i=n-1; i>1; i--) { n = n*i; } return n; } else if (n<0) throw new ArgumentOutOfRangeException("n","n should be non-zero"); else return 1; } } }
run
|
edit
|
history
|
help
0
switch it
Homework1
rzError
TestWall
Pets Name Generator
towers of hanoi
Function Tester
a5
Armstrong
Shift Example