(* Collatz conjecture *) (* If, odd, increase the number, otherwise, decrease it *) x = 27; y = {x}; While(x > 1, x = If(Mod(x, 2) == 1, x*3+1, x/2); y = Append(y, x) ); y Print(Length(y), " iterations"); (* Collatz conjecture *) (* Anonymous function and built-in Wolfram function *) x = 27; y = NestWhileList(If(Mod(#, 2) == 1, #*3+1, #/2)&, x, # > 1&); y Print(Length(y), " iterations");