Question: I am having a problem with the 3 N+1

I am trying to get the output listed into a vector or list, but I am unsuccessful. I get the error code "improper sequence". but the expression works:

N:=24

while N>1 do if evalb(type(N,even)=true) then N:=N/2;print(N);else N:=3*N+1;print(N);end if;end do;

The output generated is:

12

6

10

5

16

8

4

2

1

I would like to have the output as a list or a vector with two numbers, the number of times it took to reduce N to one and of course 1 itself. How do I go about either creating a procedure or vector or a list?

Please Wait...