Last active
June 19, 2017 21:07
-
-
Save effective-light/68a1c00d2806fe0461cc6d05d65ab4c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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