Advertisement
thekin

Collatz Conjecture Bruteforcer

Jan 9th, 2021 (edited)
1,248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # Chances state this entire thing is stupid and none of our computers even combined in processing speed can actually beat it.
  2. stored = 1
  3. current = stored
  4.  
  5. while True:
  6.     current = current // 2 if current % 2 == 0 else current * 3 + 1
  7.  
  8.     # Increment 1 since this just means we're stuck in a loop since 1 * 3 + 1 is 4 then / 2 is 2 / 2 again is 1.
  9.     if current == 1:
  10.         stored += 1
  11.         current = stored
  12.  
  13.     # If we beat the loop, break out of the while loop printing which number broke it.
  14.     if current == 0:
  15.         print(current, ":", stored)
  16.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement