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.
1 parent a61b05b commit 5cdb85dCopy full SHA for 5cdb85d
maths/binomial_coefficient.py
@@ -0,0 +1,28 @@
1
+# Python program to find binomial coefficient using pascals triangle.
2
+
3
+def solve(n,r):
4
5
6
+ C = [0 for i in range(r+1)]
7
8
+ # nc0 = 1
9
+ C[0] = 1
10
11
+ for i in range(1,n+1):
12
13
+ #to compute current row from previous row.
14
+ j = min(i ,r)
15
16
+ while (j > 0):
17
+ C[j] = C[j] + C[j-1]
18
+ j -= 1
19
20
+ return C[r]
21
22
+#sample Data
23
+n = 10
24
+r = 5
25
26
+print (solve(n,r))
27
28
0 commit comments