Compute all primes smaller than or equal to square root of n using simple sieve
int limit = floor ( sqrt ( n ) ) + 1 ; vector < int > prime ; prime . reserve ( limit ) ; simpleSieve ( limit , prime ) ;