We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a33de39 + a52a88b commit f9d41a3Copy full SHA for f9d41a3
Arrays/NCRcombination.c
@@ -0,0 +1,28 @@
1
+#include <stdio.h>
2
+
3
+int fact(int n)
4
+{
5
+ if(n==0)return 1;
6
+ return fact(n-1)*n;
7
+}
8
+int nCr(int n,int r)
9
10
+ int num,den;
11
12
+ num=fact(n);
13
+ den=fact(r)*fact(n-r);
14
15
+ return num/den;
16
17
+int NCR(int n,int r)
18
19
+ if(n==r || r==0)
20
+ return 1;
21
+ return NCR(n-1,r-1)+NCR(n-1,r);
22
23
24
+int main()
25
26
+ printf("%d \n",NCR(5,3));
27
+ return 0;
28
0 commit comments