Skip to content

Instantly share code, notes, and snippets.

@hasasn
Created May 19, 2015 19:25
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 hasasn/79081a6a25ae617f4e61 to your computer and use it in GitHub Desktop.
Save hasasn/79081a6a25ae617f4e61 to your computer and use it in GitHub Desktop.
print('Enter Number:')
mynum = int(input())
def collatz(number):
seq = [number]
while seq[-1] >1:
if number%2 == 0:
seq.append(number/2)
else:
seq.append(3*number+1)
number = seq[-1]
return seq
print(collatz(mynum))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment