Modular multiplicative inverse

please suggest me the most opptised algo (preferably in java) to find the Modular multiplicative inverse

i am using this till now:-




static int modInverse(int a, int m)
{
a = a % m;
for (int x = 1; x < m; x++)
if ((a * x) % m == 1)
return x;
return 1;
}
Topic archived. No new replies allowed.