Question: The Collatz Conjecture

I have a maple homework on the collatz conjecture, but i am new to maple and does not know how to program it.

our professor gave us the first part, i tried a lot of different loop, but keep getting errors. Need HELP.

I need to test all integer m <= 60, i dont know how to set up a loop that can test all 60 numbers.

> restart;

> k := proc (x) options operator, arrow; piecewise(type(x, even), (1/2)*x, 3*x+1) end proc;
/ 1 \
x -> piecewise|type(x, even), - x, 3 x + 1|
\ 2 /

> m := 3;
> k(m);
> for j to 200 while k(%) > 1 do k(%) end do;
> print(m, j+1);

 

Please Wait...