Skip to content

Instantly share code, notes, and snippets.

@astronomy88 astronomy88/sieve_mod.rb
Last active Aug 29, 2015

What would you like to do?
end_value = 120
#-- Using mod
a = Array(2..end_value)
limit = Math.sqrt end_value
a.each do |x|
a.delete_if do |y|
next if y <= x
y % x == 0
break if x >= limit
puts "Primes: #{a}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.