Skip to content

Instantly share code, notes, and snippets.

@javi830810
Created October 15, 2015 14:52
Show Gist options
  • Select an option

  • Save javi830810/727f8ef0fd31a77a63e5 to your computer and use it in GitHub Desktop.

Select an option

Save javi830810/727f8ef0fd31a77a63e5 to your computer and use it in GitHub Desktop.
def pow(a,b):
if b == 0:
return 1
if b == 1:
return a
if b % 2 == 1:
return pow(a,b/2)*pow(a,b/2)*a
if b % 2 == 0:
return pow(a,b/2)*pow(a,b/2)
print pow(2,5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment