Skip to content

Instantly share code, notes, and snippets.

@stripe-q
Created December 21, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripe-q/b417ad955db600a886fcea82b22ff687 to your computer and use it in GitHub Desktop.
Save stripe-q/b417ad955db600a886fcea82b22ff687 to your computer and use it in GitHub Desktop.
# 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