int main(void) { int N; input(&N); bool candidates[N]; fillTrue(candidates, N); sieveEratosthenes(candidates, N); print(candidates, N); return 0; }
int main() { int n = 500000000; // it turns out this upper limit can be a lot smaller bool *primes = sieveEratosthenes(n); int i = 3; while (true) { while (primes[i]) i += 2; // get next odd composite number if(!isSumOfPrimeAndTwiceASq(i, primes)) break; i += 2; } std::cout << "The solution is " << i << std::endl; return 0; }
int main() { int n = 1000000; int sum = 0; int count = 0; bool *primes = sieveEratosthenes(n); for (int i = 10; i <= n; i++) { if (isTruncLeftToRight(i, primes) && isTruncRightToLeft(i, primes)) { count++; sum += i; } } std::cout << "We can confirm that there are " << count << " such truncatable primes. The solution is " << sum << std::endl; return 0; }
int main() { int N = 1000000; /* create an array of all primes less than N */ bool *P = sieveEratosthenes(N); std::vector<int> allPrimesUnderN; for (int i = 0; i < N + 1; i++) { if (P[i]) allPrimesUnderN.push_back(i); } // done int count = 0; for (int i = 0; i < allPrimesUnderN.size(); i++) { if (isPrimeCircular(allPrimesUnderN[i], P)) count++; } std::cout << "The solution is " << count << std::endl; return 0; }