Rakeshgombi / Hactoberfest-2021

Repository for Hactoberfest
https://hacktoberfest.digitalocean.com/
22 stars 90 forks source link

remainder for exponent numbers using binary exponentiation #84

Closed Pratyush-IITBHU closed 2 years ago

Pratyush-IITBHU commented 2 years ago

Hello Sir, This is my code to find the remainder when an exponent is divided by an integer, using binary exponentiation with remainderisation at each recursion(step).

Sometimes a^b becomes so large that it is not possible for us to first evaluate it and then find the remainder when it is divided by any integer. So for large b, we use binary exponentiation with remainderisation at each step to evaluate remainder without evaluating actual number.

we will use following property of remainder: (ab)%c=((a%c)(bc))c)