Why can one stop in the sieve when p2>Np^2>N? The reason is simple and concerns every composite number.

Remark — Why it is enough to stop at N\sqrt{N}

If nNn\le N were composite, then n=abn=a\cdot b with 1<ab1<a\le b. It follows that anNa\le\sqrt{n}\le\sqrt{N}: the smaller factor is N\le\sqrt{N}. So every composite number N\le N has a prime factor N\le\sqrt{N} and has already been crossed out when the multiples of the primes up to N\sqrt{N} were eliminated. The cost of the sieve is O(NloglogN)O(N\log\log N): for N=106N=10^6 a few milliseconds are enough.

Topics: Numbers and operations
Concepts: Sieve of Eratosthenes · Prime number
Skills: Prove