prateek bhaiyas way works only for positive numbers please tell how to account for negative nuymbers
How to aacount for negative numbers in the given question
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.
please help as i have got no replies
hey @harryson if the base is negative then perform the regular modular exponentiation and if the exponent is even the answer would remain the same else multiply the answer with -1 and do ans = (ans + mod)%mod