solution/cw2/collatz.while
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 28 Oct 2022 09:08:13 +0100
changeset 893 54a483a33763
parent 864 b5b1bc0a603b
permissions -rw-r--r--
updated

write "Input a number ";
read n;
while n > 1 do {
  if n % 2 == 0 
  then n := n / 2 
  else n := 3 * n + 1;
};
write "Yes\n";