Skip to content

Instantly share code, notes, and snippets.

@theabbie
Created October 11, 2022 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theabbie/b7fc6179c4af3b10a7181df469f7efe6 to your computer and use it in GitHub Desktop.
Save theabbie/b7fc6179c4af3b10a7181df469f7efe6 to your computer and use it in GitHub Desktop.
Iterative binary exponentiation
def pow(a, b):
curr = a
res = 1
while b:
if b & 1:
res *= curr
b = b >> 1
curr *= curr
return res
print(pow(58, 595))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment