solution/cw3/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 20 Jan 2022 08:58:38 +0000
changeset 868 8fb3b6d3be70
parent 864 b5b1bc0a603b
permissions -rw-r--r--
updated to Doubles trhoughout

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