cwtests/cw02/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 24 Sep 2021 13:35:42 +0100
changeset 837 499405058cfd
parent 833 aad5957eb7e4
child 853 568671822d52
permissions -rw-r--r--
updated

// 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
}