#include #include #include #include // #include "SieveOfEratosthenes.hpp" using namespace std; template class Primes { public: constexpr Primes() { bool b[N]{0}; for (size_t i = 2; i <= N; i++) if (!b[i-1]) for (size_t j = 2 * i; j <= N; j += i) b[j-1] = 1; for (size_t i = 1; i < N; i++) if (!b[i]) arr[n++] = i+1; }; size_t n = 0; array arr{}; }; int main () { constexpr Primes< 262144U > primes; ofstream out("out.txt"); for (size_t i = 0; i < primes.n; i++) out << primes.arr[i] << endl; out.close(); }