You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
283 B
Python

# https://en.wikipedia.org/wiki/Exponentiation_by_squaring
def pow(a, b, mod):
res = 1
while b > 0:
if b & 1 != 0:
res = res * a % mod
a = a * a % mod
b >>= 1
return res
def test():
print(1024 == pow(2, 10, 1000000007))
test()