sir my code is giving runtime error whenenever ans%m is done why is that so link is https://ide.codingblocks.com/s/138892
Doubt in fast modulo exponentiation
Here’s the problem
When you do
a=(a*a); //problem
a=(a%m);
‘a’ might overflow.
So we shall use this:
a=((a%m)*(a%m))%m; //property of modulo
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.