Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ringowang/319de243abaff7b6e33e250c206202e7 to your computer and use it in GitHub Desktop.
Save ringowang/319de243abaff7b6e33e250c206202e7 to your computer and use it in GitHub Desktop.
Eloquent JavaScript 3.9 递归里面的函数 Python实现
def find_solution(target):
def find(current, history):
if current == target:
return history
elif current > target:
return None
else:
return find(current + 5, "({} + 5)".format(history)) or find(current * 3, "({} * 3)".format(history))
return find(1, "1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment