Created
December 21, 2018 02:53
-
-
Save stripe-q/b417ad955db600a886fcea82b22ff687 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
# 200만 이하의 소수의 합 | |
# 에라토스테네스의 체로 구한다. | |
@time let n = 2000000 | |
s = trues(n) | |
s[1] = false | |
for i=2:n | |
if s[i] | |
s[i+i:i:end] = falses((n-i) ÷ i) | |
end | |
end | |
sum(i for i=1:n if s[i]) |> println | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment