Modular exponentiation

i coded the program for this problem by using modular exponentiation technique. but when i submit the same then i get 9/10test cases passed but only 1 test case is not passing. why is this so? what am i doing wrong please somebody help me?

this is my code

hello @pushkar24sharma i have corrected your code and now it is passing all the test cases .


Happy Learning !!

1 Like

@tusharaggarwal272ok thank u sir now it is working. but can u please explain me why was it incorrect to initiallise our ans with a. u initiallised it with a%c then only it is working. what is wrong with initialisation of ans with a only??

i have made one correction below as well .
both the corrections together made the code coorect .

1 Like

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.