progs/while-tests/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 19 Dec 2020 00:13:58 +0000
changeset 820 9d5e4fa0c64d
parent 742 155426396b5f
child 824 fb5462a350b1
permissions -rw-r--r--
updated

// 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";
f := 2;
while n != 1 do {
    while (n / f) * f == n do {
        write f;
        n := n / f
    };
    f := f + 1
}