Skip to main content

Posts

Showing posts with the label Large

Power of large numbers

If you have to calculate pow(a,b)%mod. where a and b are large numbers like 10^100000(100000 digits) and mod is any prime number.  In programming language like C,C++,python it is very difficult to process such a large data. So here is a method to solve that problem. First assign a=a%mod b=b%(mod-1) then calculate pow(a,b)%mod.