Skip to content

Instantly share code, notes, and snippets.

@Kfir-G
Created June 14, 2024 10:59
Show Gist options
  • Save Kfir-G/e664ad23b94d1ec8256e582c7c4784dc to your computer and use it in GitHub Desktop.
Save Kfir-G/e664ad23b94d1ec8256e582c7c4784dc to your computer and use it in GitHub Desktop.
Recursion to illustrate the cat and mirror story
def reflect_cat(reflections_left):
if reflections_left == 0:
return "A cat sees itself."
else:
return f"A cat sees {reflect_cat(reflections_left - 1)}"
# Start the recursion with 5 reflections
print(reflect_cat(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment