summaryrefslogtreecommitdiff
path: root/math/test/binomial0.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-04-01 01:06:05 +0200
committerGloria Mundi <gloria@gloria-mundi.eu>2024-04-01 01:06:05 +0200
commit4fc39dcd54243609febc1ce4c8a1470b3d31fd47 (patch)
treed5ab175c47f15fce8db310afc4575f0237f7c49b /math/test/binomial0.cpp
parentf66e5c754556e25e339725754ff511c012c3c440 (diff)
fix binomial0 & add test
Diffstat (limited to 'math/test/binomial0.cpp')
-rw-r--r--math/test/binomial0.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/math/test/binomial0.cpp b/math/test/binomial0.cpp
new file mode 100644
index 0000000..d6c3a03
--- /dev/null
+++ b/math/test/binomial0.cpp
@@ -0,0 +1,21 @@
+constexpr ll mod = 1'000'000'007;
+
+#include "../shortModInv.cpp"
+#include "../binomial0.cpp"
+
+int main() {
+ precalc();
+ assert(calc_binom(5, -1) == 0);
+ assert(calc_binom(5, 0) == 1);
+ assert(calc_binom(5, 1) == 5);
+ assert(calc_binom(5, 2) == 10);
+ assert(calc_binom(5, 3) == 10);
+ assert(calc_binom(5, 4) == 5);
+ assert(calc_binom(5, 5) == 1);
+ assert(calc_binom(5, 6) == 0);
+ assert(calc_binom(0, 0) == 1);
+ assert(calc_binom(-1, 0) == 0);
+ assert(calc_binom(-1, -1) == 0);
+ assert(calc_binom(-1, -2) == 0);
+ assert(calc_binom(100'000, 50'000) == 149033233);
+}