Skip to content

Instantly share code, notes, and snippets.

@arashrasoulzadeh
Created August 3, 2021 10:26
Show Gist options
  • Save arashrasoulzadeh/e8c5dbad36e287aa870fa8e9c86b2d24 to your computer and use it in GitHub Desktop.
Save arashrasoulzadeh/e8c5dbad36e287aa870fa8e9c86b2d24 to your computer and use it in GitHub Desktop.
Collatz Conjecture
number=100
def odd(n):
return n % 2 != 0
def calc(n):
print(n)
if odd(n):
n=(n*3)+1
else:
n=n/2
if n != 1:
return calc(n)
print(" and back to 1")
return
calc(number);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment