I need to write a program that calculates the sum of all primes smaller than a given number $N$
($10^{10} \leq N \leq 10^{14} $).
Obviously, the program should run in a reasonable time, so $O(N)$ is not good enough.
I think I should find the sum of all the composite numbers smaller than $N$ and subtract it from $1+2+…+N$, but I'm trying that for a long time with no progress.
Best Answer
Lucy_Hedgehog's post on Project Euler forum about problem 10 (visible after logging in):
I've checked with pen and Python - according to me, it works as described: