a = 100000000
c = (2**(a-1))-1
b = (2<<(a-1))-1
m = 1000000007
print b%m
print c%m
Output :
494499947
247249973
I am using ** and << operator in python to find powers of 2 raised to a very large number . However similar operations give different result. Just curious why?
The results are different because the equivalent of 2 ** n
is 1 << n
, not 2 << n
.