diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-08 23:06:01 +0200 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-08 23:06:01 +0200 |
| commit | f5316545b46edfc511b628430cd883ca2c56f1ca (patch) | |
| tree | b6bd3656a1feb8603be51f1974e715efd49a3e59 /math/multInv.cpp | |
| parent | e452172df888771469ee27e55e940aa0ca66d86a (diff) | |
New extended euclid code without global variables.
Diffstat (limited to 'math/multInv.cpp')
| -rw-r--r-- | math/multInv.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/math/multInv.cpp b/math/multInv.cpp index 858e47c..2aedcd6 100644 --- a/math/multInv.cpp +++ b/math/multInv.cpp @@ -1,6 +1,7 @@ // Laufzeit: O(log (n) + log(p)) -ll multInv(ll n, ll p) { // Berechnet das multiplikative Inverse von n in F_p. - extendedEuclid(n, p); // Implementierung von oben. +ll multInv(ll n, ll p) { + ll x, y; + extendedEuclid(n, p, x, y); // Implementierung von oben. x += ((x / p) + 1) * p; return x % p; } |
