plz help me out
Modular Exponentiation
Hello @akb.tech17,
The logic you have applied would fail for large values of a, b and c like:
99999, 100000 and 100000 resp.
Hint: Study about exp. by squaring method algorithm.
Refer to this link.
Hope, this would help.
Give a like if you are satisfied.
hello @akb.tech17,
This is in response of your message:
Suppose we have to compute a^n.
and t=a^(n/2);
There are two cases here:
-
When n is even:
So, we can write it as:
a^n=(a^(n/2))(a^(n/2))=tt -
When n is odd:
a^n=(a^(n/2))(a^(n/2))a=tta;
So, in the program you have shared, we are computing t i.e. a^(n/2) recursively.
Give a like if you are satisfied.
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.