Skip to content

Commit ecad8e5

Browse files
authored
Create mmi.py
1 parent 6bf9496 commit ecad8e5

File tree

1 file changed

+17
-0
lines changed
  • Math/modular_multiplicative_inverse

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Python 3 program to find modular
2+
# inverse of a under modulo m
3+
4+
# A naive method to find modulor
5+
# multiplicative inverse of 'a'
6+
# under modulo 'm'
7+
def modInverse(a, m) :
8+
a = a % m;
9+
for x in range(1, m) :
10+
if ((a * x) % m == 1) :
11+
return x
12+
return 1
13+
14+
# Driver Program
15+
a = 3
16+
m = 11
17+
print(modInverse(a, m))

0 commit comments

Comments
 (0)