Last active
August 29, 2015 13:57
-
-
Save astronomy88/9635685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
end | |
break if x >= limit | |
end | |
puts "Primes: #{a}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment