Multiplicative inverse problem

Why can’t we solve this problem using extended euclidean algorithm

hi @Devforlife07, it can be solved using extended euclid algo
check this code :- https://ide.codingblocks.com/s/269860

Thank You so much I did exactly same as your code except the last line where you added 10^9+7 and taken mod with it.Please tell why are we doing so in last statement that cout one

Sir please reply?? ?

@Devforlife07,
when you are computing int A.y=B.x-(a/b)*B.y; you are performing subtraction which might result in negetive values . so (ans+mod)%mod ensures the case of negetive numbers

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.