Skip to content

Instantly share code, notes, and snippets.

@amadamala
Created April 29, 2011 14:11
Show Gist options
  • Save amadamala/948353 to your computer and use it in GitHub Desktop.
Save amadamala/948353 to your computer and use it in GitHub Desktop.
Collatz sequence
N = 1001
def collatz_sequences(n):
while n > 1:
print n
if (n % 2) != 0:
n = (3 * n) + 1
else:
n = n / 2
print n
if __name__ == '__main__':
collatz_sequences(N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment