solutions/cw2/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 09 Sep 2023 14:14:31 +0100
changeset 916 10f834eb0a9e
parent 894 02ef5c3abc51
child 920 7af2eea19646
permissions -rw-r--r--
texupdate

// Find all factors of a given input number
// by J.R. Cordy August 2005

write "Input n please";
read n;
write "The factors of n are\n";
f := 2;
while n != 1 do {
    while (n / f) * f == n do {
        write f; write "\n";
        n := n / f
    };
    f := f + 1
}