Skip to content

Commit fdebb9c

Browse files
Merge pull request #573 from goflora/patch-2
Create modularMultiplicativeInverse.py
2 parents 8c85076 + a5a0f55 commit fdebb9c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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))
18+

0 commit comments

Comments
 (0)