Doubt in little fermat theoram to find inverse?

If i want to find the inverse of 15 with respect 4
then
a^(p-2) mod p will give me the answer
15^2 = 225
and 225 % 4 = 1
but (15*1) % 4 = 3 and not 1 hence 1 is not the answer
How?

hello @deepak_four there is condition in the litte fermats theore that a^(p-1)%p=1 only when p is a prime number ,
and in your query 4 is not the prime number.
Happy Learning !!

Okay,
So to find the multiplicative inverse we need to use the euclid approach, Is there any other way?

Yes euclid approach.
the another approach will be the brute force approach.
if you feel that your doubt is cleared please mark this doubt as resolved.
Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.