progs/while-tests/primes.while
changeset 742 b5b5583a3a08
parent 674 e0a41a1f24cf
child 750 e93a9e74ca8e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/while-tests/primes.while	Thu Jul 30 13:50:54 2020 +0100
@@ -0,0 +1,15 @@
+// prints out prime numbers from
+// 2 to 100 (end)
+
+end := 100;
+n := 2;
+while (n < end) do {
+  f := 2;
+  tmp := 0;
+  while ((f < n / 2 + 1) && (tmp == 0)) do {
+    if ((n / f) * f == n) then  { tmp := 1 } else { skip };
+    f := f + 1
+  };
+  if (tmp == 0) then { write(n) } else { skip };
+  n  := n + 1
+}
\ No newline at end of file