Created
August 1, 2012 14:29
-
-
Save yuuki/3227327 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
r = (2..2000000).select do |i| | |
!(2..Math.sqrt(i).floor).find {|j| i % j == 0 } # 素数判定 | |
end.inject(:+) | |
puts r | |
# 142913828922 | |
# 30.40s with Core i5 mem 4G |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment