Question: Why can't I use this while in a procedure?

I want to use while in proc but Maple shows an error saying

 

"Error, (in exa) illegal use of a formal parameter"

 

When I click on it, as usual it says "There is no help page available for this error". I tried a very simple example of while which you can see it below and it again shows same error. The while works well but when I put it inside of a procedure it makes an error. Note: the following example is just an example, this is not what I'm doing so please don't reply this while proc is not giving anything. My question is how can I use a while in procedure without encountering the above error.

 

i := 10;
while i > 1 do
if i mod 2 = 0 then i := i/2; else i := i+1; end if;
end do;

 

Now with proc

 

exa := proc (i::integer)::integer;
while 1 < i do
if i mod 2 = 0 then i :=i/2; else i := i+1; end if
end do; 
end proc;

exa(10);

"Error, (in exa) illegal use of a formal parameter"

Please Wait...