progs/primes.while
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 20 Jul 2020 10:06:43 +0100
changeset 735 fc2e3609d5e5
parent 674 e0a41a1f24cf
permissions -rw-r--r--
updatd

// 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
}