How to proceed for calculating the multiplicative inverse of number when M is not prime.
Eg. if M= 7 the MMI of 4 is 2 as
( 4 * 2 ) %7 ==1
,
if M=11, the MMI of 7 is 8 as
( 7 * 8 )%11 ==1
,
if M=13, the MMI of 7 is 2 as
( 7 * 2 ) % 13==1
.
When M and the other number are co-prime,only then it can be calculated as above.
Is there a way to do it when they are not co-prime?
How to solve such problems?
Thanks!
The modular multiplicative inverse of an integer x modulo m is (x^(ETF(m)-1))%m where ETF is Euler’s Totient Function. But multiplicative inverse of x mudulo m exists only if x and m are coprime.
Thank you @acodebreaker2 and @anikaitshivam for your answers .So,inference can be drawn that,multiplicative inverse of a modulo b exists if and only if a and b are co-prime.
Euler’s totient function can be used to find modular multiplicative inverse. Is there any other way out,a simple one?
Its somewhat complicated.How to go for following:-
int a,b,m=1000;
int c=(a/b)%m;
In case of division,normal modulo properties are not applied.
**NOTE:**m is not a prime.
@aaha97
Yeah,m talking about modulo arithmetic,but for division.For eg:- (a/b)%c.This can be easily evaluated as (a*(MMI of b)%c)%c,when b and c are co-prime.What if they aren’t co-prime?