progs/while-tests/factors.while
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 06 Oct 2020 00:39:34 +0100
changeset 775 16aafc7691d8
parent 742 b5b5583a3a08
child 824 284ac979f289
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
}