Define the following variables:
n = 42 iterations = 0
While the value of n
is different from 1, apply the following logic:
n
is even, divide it by 2n
is odd, triple it and add oneiterations
by 1Note: How do we know this loop always finishes, i.e. that the value of n
will eventually reach 1? It is called the Collatz conjecture and it is an unsolved mathematical problem which asks whether repeating the rules above transforms every positive integer into 1. To date, no one has been able to show that a positive integer exists that violates the conjecture.