--- a/progs/while-tests/factors.while Thu Feb 04 10:19:48 2021 +0000
+++ b/progs/while-tests/factors.while Fri Feb 26 08:47:18 2021 +0000
@@ -1,14 +1,11 @@
// 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
+while (f < n / 2 + 1) do {
+ if ((n / f) * f == n) then { write(f) } else { skip };
+ f := f + 1
}
\ No newline at end of file