Modulo exponent

sir it is not passing all test cases. why it is to modulo on every iteration and why i can’t do modulo at last after finding exponent , as i have done in my code.

hello @tejuschaturvedi0

take modolu at every step is necessary to avoid range overflow.
if u only take modulo in the end then ur result will be wrong because of overflow

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.