algorithm to solve the Collatz conjecture