Created
March 10, 2026 05:20
-
-
Save adntaha/f592a9bf5a1a2eea5a70d6f5cfff8d16 to your computer and use it in GitHub Desktop.
Naive implementation of the Collatz conjecture: if even, divide by two, if odd, times 3 plus 1, and you'll always end up in a 4, 2, 1 loop. Curious. I'm archiving this now but I made it a while ago (~12 november 2024)
This file contains hidden or 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
| def step(n: int) -> int: | |
| return n*3+1 if n % 2 else n >> 1 | |
| for i in range(1, 1_000_000_000_000_000 + 1): | |
| n = i | |
| while n != 1: | |
| n = step(n) | |
| print(i, end=' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment