Skip to content

Instantly share code, notes, and snippets.

@pschanely
Created April 26, 2024 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pschanely/da17b77a3327f65fa80928703c8ade14 to your computer and use it in GitHub Desktop.
Save pschanely/da17b77a3327f65fa80928703c8ade14 to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
def collatz(n: int) -> int:
'''
post: __return__ == 1
'''
if n == 4:
return 1
if n % 2 == 0:
return collatz(n/2)
else:
return collatz(3*n + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment