Created
October 10, 2012 18:47
-
-
Save ox/3867619 to your computer and use it in GitHub Desktop.
find the first 10 primes
This file contains hidden or 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
(1..10).each do |n| | |
prime = true | |
(2..n-1).each do |x| | |
prime = false if n % x == 0 | |
end | |
puts n if prime | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment