We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8a6550 commit 6bf9496Copy full SHA for 6bf9496
Math/modular_multiplicative_inverse/mmi.java
@@ -0,0 +1,25 @@
1
+// Java program to find modular inverse
2
+// of a under modulo m
3
+import java.io.*;
4
+
5
+class GFG {
6
7
+ // A naive method to find modulor
8
+ // multiplicative inverse of 'a'
9
+ // under modulo 'm'
10
+ static int modInverse(int a, int m)
11
+ {
12
+ a = a % m;
13
+ for (int x = 1; x < m; x++)
14
+ if ((a * x) % m == 1)
15
+ return x;
16
+ return 1;
17
+ }
18
19
+ // Driver Program
20
+ public static void main(String args[])
21
22
+ int a = 3, m = 11;
23
+ System.out.println(modInverse(a, m));
24
25
+}
0 commit comments