Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 15 lines (13 sloc) 0.245 kb
511dc44 initial import
Laurent Sansonetti authored
1 # sieve of Eratosthenes
2 max = Integer(ARGV.shift || 100)
3 sieve = []
4 for i in 2 .. max
5 sieve[i] = i
6 end
7
8 for i in 2 .. Math.sqrt(max)
9 next unless sieve[i]
10 (i*i).step(max, i) do |j|
11 sieve[j] = nil
12 end
13 end
14 puts sieve.compact.join(", ")
Something went wrong with that request. Please try again.