Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created August 1, 2012 14:29
Show Gist options
  • Save yuuki/3227327 to your computer and use it in GitHub Desktop.
Save yuuki/3227327 to your computer and use it in GitHub Desktop.
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