Skip to content

Instantly share code, notes, and snippets.

@effective-light
Last active June 19, 2017 21:07
Show Gist options
  • Save effective-light/68a1c00d2806fe0461cc6d05d65ab4c2 to your computer and use it in GitHub Desktop.
Save effective-light/68a1c00d2806fe0461cc6d05d65ab4c2 to your computer and use it in GitHub Desktop.
def pow_r(x, n):
if n == 0:
return 1
return multiply(x, pow_r(x, n - 1))
def multiply(f1, f2):
def _multiply(a, b):
if b == 1:
return a
return a + multiply(a, b - 1)
if f1 < f2:
return _multiply(f2, f1)
return _multiply(f1, f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment