//OPT: -lpthread #include #include #include #include #include using namespace std; typedef long long itype; // This is not an example of how to calculate primes if you have multiple // processors. It is an example of how C++ supports threading in C++11 // (do not use this algorithm for anything other than to chew up CPU time) bool isprimesub(itype num, itype s, itype e) { if (s<2) s=2; for(itype x=s;x ts; for(int i=0;i> num; int nthread = 1; if (argc>2) { stringstream ss(argv[2]); ss >> nthread; } cout << num << (isprime(num,nthread) ? " is prime" : " is not prime") << endl; }