First page Back Continue Last page Overview Image

Collatz Conjecture

Take any natural number n.

If n is even, divide it by 2 to get n / 2.

If n is odd, multiply it by 3 and add 1 to obtain 3n + 1.

Repeat the process (which has been called "Half Or Triple Plus One", or HOTPO) indefinitely.

The conjecture is that no matter what number you start with, you will always eventually reach 1. The property has also been called oneness. Paul Erdös said about the Collatz conjecture: "Mathematics may not be ready for such problems." He also offered $500 for its solution.

That smallest i such that ai = 1 is called the total stopping time of n. The conjecture asserts that every n has a well-defined total stopping time. If, for some n, such an i doesn't exist, we say that n has infinite total stopping time and the conjecture is false.

Write a function StoppingTime which returns the stopping time for a number n.