summaryrefslogtreecommitdiff
path: root/math/binomial3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/binomial3.cpp')
-rw-r--r--math/binomial3.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/math/binomial3.cpp b/math/binomial3.cpp
index 760f2eb..f52337c 100644
--- a/math/binomial3.cpp
+++ b/math/binomial3.cpp
@@ -1,5 +1,6 @@
ll calc_binom(ll n, ll k, ll p) {
- if (n >= p || k > n) return 0;
+ assert(n < p) //wichtig: sonst falsch!
+ if (k > n) return 0;
ll x = k % 2 != 0 ? p-1 : 1;
for (ll c = p-1; c > n; c--) {
x *= c - k; x %= p;