-- -*- mode: eiffel -*-
-- $Id: sieve.se,v 1.4 2001/06/10 04:23:34 doug Exp $
-- http://www.bagley.org/~doug/shootout/
class SIEVE
creation make
feature
make is
local
count: INTEGER;
flags: ARRAY[CHARACTER];
i: INTEGER;
num: INTEGER;
j: INTEGER;
k: INTEGER;
do
if argument_count = 1 then
num := argument(1).to_integer
else
num := 1
end
!!flags.make(0, 8193)
from
j := 0
until
j = num
loop
count := 0
from
i := 2
until
i > 8192
loop
flags.put('t', i)
i := i + 1
end
from
i := 2
until
i > 8192
loop
if flags.item(i) = 't' then
from
k := i + i
until
k > 8192
loop
flags.put('f', k)
k := k + i
end
count := count + 1
end
i := i + 1
end
j := j + 1
end
std_output.put_string("Count: ")
std_output.put_integer(count)
std_output.put_character('%N')
end;
end