Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def modexp(a, n, m):
- b = []
- while n:
- b.append(n%2)
- n /= 2
- power = 1
- b.reverse()
- for x in b:
- power = (power*power)%m
- if x:
- power = (power*a)%m
- return power
- print (modexp (2,34, pow(10,10)))
- print (modexp (2,pow(10,20), pow(10,10)))
Add Comment
Please, Sign In to add comment