Skip to content

Instantly share code, notes, and snippets.

@kevingoldsmith
Created August 13, 2021 06:23
Show Gist options
  • Save kevingoldsmith/b25687cb8f47f8caa27c5c6f7136098f to your computer and use it in GitHub Desktop.
Save kevingoldsmith/b25687cb8f47f8caa27c5c6f7136098f to your computer and use it in GitHub Desktop.
playing around with demonstrating the Collatz Conjecture
# https://en.wikipedia.org/wiki/Collatz_conjecture
proven = {1}
top_bound = 1000
for n in range(1, top_bound):
current = n
while current not in proven:
if (current % 2) == 0:
current = int(current / 2)
else:
current = int(3*current+1)
print(f'{n}\t{current}')
if current in proven:
proven.add(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment