Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- max = Integer(ARGV.shift || 100)
- sieve = [nil, nil] + (2 .. max).to_a
- (2 .. Math.sqrt(max)).each do |i|
- next unless sieve[i]
- (i*i).step(max, i) do |j|
- sieve[j] = nil
- end
- end
- puts sieve.compact.join(", ")
Add Comment
Please, Sign In to add comment