Question: help me to correct this error

Collatz := proc (n)

    local count;

       while n != 1 do

           if `mod`(n, 2) = 0 then n := (1/2)*n

           else n := 3*n+1

           end if;

           count := count+1;

       end do;

print(count);

end proc:

 

I wanna correct 'illegal use of formal parameter' error.

'n' always goes to 1 through 'while statement'.

Please Wait...