solutions/cw2/collatz.while
changeset 894 02ef5c3abc51
parent 864 b5b1bc0a603b
child 920 7af2eea19646
equal deleted inserted replaced
893:54a483a33763 894:02ef5c3abc51
       
     1 write "Input a number ";
       
     2 read n;
       
     3 while n > 1 do {
       
     4   if n % 2 == 0 
       
     5   then n := n / 2 
       
     6   else n := 3 * n + 1;
       
     7 };
       
     8 write "Yes\n";