0

I want to calculate a^b%m where a,b and m are very large number like 2^256 or 2^512 bit. As far I know some method called bigmod or powmod which calculate a^b%m in O(log m) time complexity but as the number is huge we need to implement it using BigIntegers. Which is slower than normal arithmetic operation. So for this job I have implemented my own Biginteger library and implemented a O(log m) algorithm to calculate a^b%m. But it is using minimum 7-8 seconds to execute where python pow(a,b,m) function is working in less than 1 second. So I want to know the details about the algorithm which is used to implement pow(a,b,m).

President James K. Polk
  • 38,341
  • 16
  • 90
  • 119
Tanmoy Datta
  • 1,368
  • 15
  • 13

0 Answers0