Skip all even numbers since they're all divisible by 2.

This commit is contained in:
Nicolás A. Ortega 2016-12-01 12:21:09 +01:00
parent 1593e57e90
commit 05b6257e44
No known key found for this signature in database
GPG Key ID: 614272579C2070D1

View File

@ -16,7 +16,7 @@ int main(void) {
std::vector<unsigned long long> primes; std::vector<unsigned long long> primes;
primes.push_back(2); primes.push_back(2);
unsigned long long num = 2; unsigned long long num = 3;
// Use for to accomodate for OpenMP // Use for to accomodate for OpenMP
#pragma omp parallel #pragma omp parallel
@ -26,7 +26,7 @@ int main(void) {
#pragma omp critical #pragma omp critical
{ {
myNum = num; myNum = num;
++num; num += 2;
} }
bool isPrime = true; bool isPrime = true;
#pragma omp barrier #pragma omp barrier