Skip to content

Instantly share code, notes, and snippets.

@hovissimo
Forked from Neemox/collatzFunc.py
Last active April 29, 2016 21:57
Show Gist options
  • Save hovissimo/5748c9bf54b3f0babc2bfdda74d17600 to your computer and use it in GitHub Desktop.
Save hovissimo/5748c9bf54b3f0babc2bfdda74d17600 to your computer and use it in GitHub Desktop.
def collatz():
global number
if number % 2 == 0:
number = number // 2
print(number)
return number
else:
number = number * 3 + 1
print(number)
return number
print('Please enter a number for the Collatz sequence:')
number = int(input())
while number != 1:
number = collatz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment