%const %integer  true  = 1
%const %integer  false =  0
%const %integer  size  = 1024*1024

%own %byte %array flags(0:size)   { %own for strict compatibility }

%begin
%integer i,prime,k,count,iter
  printstring("10 iterations
");
  %for iter = 1, 1, 10 %cycle
    count = 0;
    flags(i) = true %for i = 0, 1, size
    %for i = 0, 1, size %cycle
      %if flags(i)#false %start
        prime = i + i + 3;
        k = i+prime
        %while k <= size %cycle
          flags(k) = false
          k = k+prime
        %repeat
        count = count + 1
      %finish
    %repeat
  %repeat
  write(count,0)
  print string(" primes.
")
%endofprogram
