'Sieve of Eratosthenes
uses console
%max 200
int n[max]
int q=0
int p=2 'first prime
int i
print "Primes from 2.." & max & chr(13,10)
do
  for i=p*2 to max step p
    n[i]=1 'mark multiples of prime as non-prime
  next
  q=0
  for i=p+1 to max
    if n[i]=0
      q=i 'next prime located
      print i & chr(9)
      exit for
    end if
  next
  if q=0 then exit do 'no more primes
  p=q
end do
WaitKey


