# -*- mode: icon -*-
# $Id: sieve.icon,v 1.3 2000/12/17 23:34:06 doug Exp $
# http://www.bagley.org/~doug/shootout/

procedure main(argv)
    n := argv[1] | 1
    every i := 1 to n do count := sieve()
    write("Count: ", count)
end

# algorithm from a test program that is distributed with
# the icon source

procedure sieve()
   local limit, s, i
   limit := 8192
   s := set()
   every insert(s,1 to limit)
   every member(s,i := 2 to limit) do
      every delete(s,i + i to limit by i)
   delete(s,1)
   return(*s);
end