cwtests/cw02/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 03 Dec 2021 21:56:55 +0000
changeset 856 23273e3a120f
parent 853 568671822d52
child 860 6f80e6df34f7
permissions -rw-r--r--
updated

// Find all factors of a given input number


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