summaryrefslogtreecommitdiff
path: root/math/shortModInv.cpp
diff options
context:
space:
mode:
authorYidi <noob999noob999@gmail.com>2024-03-22 12:21:09 +0100
committerYidi <noob999noob999@gmail.com>2024-03-22 12:21:09 +0100
commit0a1fd7ed34e3a15f6ac3f646d30c9f0b6db5d3ed (patch)
tree928daca83d5a6ab4c63198dd855d180ee21a7e10 /math/shortModInv.cpp
parentdbcd02da96922c2a667ec16e390ef8263580a66c (diff)
change extended euclid
Diffstat (limited to 'math/shortModInv.cpp')
-rw-r--r--math/shortModInv.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/math/shortModInv.cpp b/math/shortModInv.cpp
index 747eb7a..244bacf 100644
--- a/math/shortModInv.cpp
+++ b/math/shortModInv.cpp
@@ -1,3 +1,3 @@
-ll inv(ll a, ll b){ // a^{-1} mod b
- return 1 < a ? b - inv(b % a, a) * b / a : 1;
-} \ No newline at end of file
+ll multInv(ll x, ll m) { // x^{-1} mod m
+ return 1 < x ? m - inv(m % x, x) * m / x : 1;
+}