Skip to content
Snippets Groups Projects
Commit 055d6c8a authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Merge branch '10-remake-modular-inverse' into 'main'

Resolve "Remake Modular inverse"

Closes #10

See merge request !9
parents e275fa49 25edc1e9
No related branches found
No related tags found
1 merge request!9Resolve "Remake Modular inverse"
# Created : 06/12/2021
# Refactored : 09/12/2021
import math
from euclide import *
# Get the multiplicvative inverse of a Mod p
# x = Multiplicative inverse of a mod p:
# a * x mod p = 1
def inverse_mult(a, p) :
c = abs(a^-1 % p)
if(p - c + abs(a) == 1):
return c
return False
pgcd, x, y = pgcd_etendu(a, p)
if pgcd != 1:
return None
if a > p:
return x
else:
return y
if __name__ == "__main__":
print(inverse_mult(3, 11))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment