fix variable name.
[ruby-svn.git] / benchmark / bm_so_sieve.rb
blobdbe2bfa63d0851a75bb6d458fe3f89afa3e7bc2d
1 # from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby
2 num = 40
3 count = i = j = 0
4 flags0 = Array.new(8192,1)
5 k = 0
6 while k < num
7   k+=1
8   count = 0
9   flags = flags0.dup
10   i = 2
11   while i<8192
12     i+=1
13     if flags[i]
14       # remove all multiples of prime: i
15       j = i*i
16       while j < 8192
17         j += i
18         flags[j] = nil
19       end
20       count += 1
21     end
22   end
23 end
24 count