Replace recursion with iteration in collatz()