Skip to content
Snippets Groups Projects
Commit 53507693 authored by quentin.fasler's avatar quentin.fasler
Browse files

edit modular_inverse

parent 032a0098
No related branches found
No related tags found
No related merge requests found
......@@ -122,16 +122,11 @@ def compute_bachet_bezout(a, b):
def modular_inverse(a, n):
res = -1
inverse = -1
i = 0
while res != 1:
if a * i % n == 1:
res = a * i % n
inverse = i
break
i += 1
return inverse
bachet_bezout = compute_bachet_bezout(a,n)
modular_inverse = bachet_bezout[0]
if a * modular_inverse % n == 1:
return modular_inverse
return None
def compute_lagrange_polynomial(points, prime_number):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment