Hacker News new | ask | show | jobs
by darkmighty 3434 days ago
What about the following?

  x=5
  y=5
  while True:
    if y%2 == 0:
      y=y/2
    else:
      y=3y+1
    if y == 1:
      x=x+1
      y=x
    if y==x:
      return x
Please predict the code. I'll even give you $500 in memory of some guy named Erdos if you get it right (and I haven't even gone for a provably undecidable example! :) )

PS: Don't waste time checking x values less than 1000000000000000000

2 comments

In theory this will eventually overflow even with pythons Arbitrary precision due to the machines finite memory. Though for practical cases it's going to run until the machine encounters an error.

If your asking the underlying math problem, yes that is true for all positive integers. It's much more obvious in base 3.

Sorry, I probably failed at writing a simple Collatz conjecture search (it should halt if Collatz is false).

https://en.wikipedia.org/wiki/Collatz_conjecture

It will run in a loop until someone turns it off. How do you want to pay up? I accept cash and Bitcoin.