MUltiplicatrive Inverse

All testcases arent correct.
Please check.

@deepna,
No, all test cases are correct, please try to use a simpler logic, a simple derivation using Fermat’s Little theorem, gives us:

(a^-1) % p = (a ^ (p - 2)) % p;

Try coding this, it would be much easier, and error free.
For more, you can read the 3rd method from here.

Sorry sir, I wasnt clear I guess I meant when I submitted my code i got few of my testcases wrong can you please tell me what is wrong in my code

@deepna,
I highly recommend to consider the approach I described above. It would be more intuitive, easier to code and debug. We can discuss if you have any problem in that code. But if you insist on this particular approach of yours, please tell me what is your logic. We can then try to debug the code.

Thank you sir, I got my approach sorted too.!