progs/while-tests/factors.while
changeset 742 b5b5583a3a08
parent 659 15b69ca63b29
child 824 284ac979f289
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/while-tests/factors.while	Thu Jul 30 13:50:54 2020 +0100
@@ -0,0 +1,14 @@
+// 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
+}
\ No newline at end of file