summaryrefslogtreecommitdiff
path: root/progs/a311.py
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-05-28 10:29:13 +0200
committerSanto Cariotti <santo@dcariotti.me>2024-05-28 10:29:13 +0200
commitf05d888a0b621ca4e99e2b0fb6e23c097006fe41 (patch)
treeeebbb2489144112d3288393e354d19375a0aa088 /progs/a311.py
Init
Diffstat (limited to 'progs/a311.py')
-rw-r--r--progs/a311.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/progs/a311.py b/progs/a311.py
new file mode 100644
index 0000000..aafdf9c
--- /dev/null
+++ b/progs/a311.py
@@ -0,0 +1,15 @@
+def binomial_coeff(n, k):
+ C = [[0 for j in range(k + 1)]
+ for i in range(n + 1)]
+ for i in range(0, n + 1):
+ for j in range(0, min(i, k) + 1):
+ if (j == 0 or j == i):
+ C[i][j] = 1
+ else:
+ C[i][j] = (C[i - 1][j - 1]
+ + C[i - 1][j])
+ return C[n][k]
+def lobb_num(n, m):
+ return (((2 * m + 1) *
+ binomial_coeff(2 * n, m + n))
+ / (m + n + 1)) \ No newline at end of file