Proving the validity of the Collatz conjecture is equivalent to proving that the following C code fragment always terminates:




    while (x >= 1) {
        if (x % 2 == 0) {
            x = x / 2;
        } else {
            x = (3 * x) + 1;
        }
    }