Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Aleksey's solution to the Collatz problem
count = 0
x = 33
while x > 1:
print("Iteration:", count, "\tx =", x)
if x % 2 == 0:
x = x / 2
else:
x = (3 * x) + 1
count += 1
print("Total number of iterations to x = 1:", count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment