Created
August 13, 2021 06:23
-
-
Save kevingoldsmith/b25687cb8f47f8caa27c5c6f7136098f to your computer and use it in GitHub Desktop.
playing around with demonstrating the Collatz Conjecture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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