Problem 10

Problem

The sum of the primes below \(10\) is \(2 + 3 + 5 + 7 = 17\).

Find the sum of all the primes below two million.

Julia

include("euler.jl")

function p10()
  Euler.sieve_of_eratosthenes(2_000_000) |> sum
end;
p10()
142913828922
using BenchmarkTools;
@benchmark p10()
BenchmarkTools.Trial: 829 samples with 1 evaluation.
 Range (minmax):  5.703 ms  6.832 ms   GC (min … max): 0.00% … 5.74%
 Time  (median):     6.005 ms                GC (median):    0.00%
 Time  (mean ± σ):   6.035 ms ± 148.188 μs   GC (mean ± σ):  1.18% ± 1.72%
              ▁▂▁▇▆▆▇█▁▆▅▃▃ ▂ ▁ ▂ ▂▁                        
  ▂▁▁▁▁▁▁▃▃▄▆▇█████████████████▅█████▆▅▆▇▆▅▅▆▄▄▇▅▃▂▃▃▄▂▃▂▂ ▅
  5.7 ms          Histogram: frequency by time        6.43 ms <
 Memory estimate: 16.63 MiB, allocs estimate: 8.