cwtests/cw02/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 03 Dec 2021 18:00:30 +0000
changeset 854 ce4a7bab6bd8
parent 853 568671822d52
child 856 23273e3a120f
permissions -rw-r--r--
testcases

// 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) } else { skip };
  f := f + 1
}