This is a simple program:

  1. Given an input x, which is a positive integer.
  2. If x is even, assign x to be x/2, else assign x to be 3x + 1.
  3. Repeat step 2 if x > 1.

Conjecture: The program will always terminate for any input x.

Believe it or not? Try to prove or disprove it yourself.


And here is the JavaScript for the above program.

please enter a positive integer:

result: