cwtests/cw02/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 04 Sep 2021 14:08:00 +0100
changeset 833 aad5957eb7e4
child 853 568671822d52
permissions -rw-r--r--
cwupdates

// Find all factors of a given input number


write "Input n please";
read n;
write "The factors of n are";
f := 2;
while (f < n / 2 + 1) do {
  if ((n / f) * f == n) then  { write(f) } else { skip };
  f := f + 1
}