#include #include const int64_t MAX_SIZE(1000); typedef std::bitset bit_arr; class PrimeNumberGenerator { private: int64_t number_start; int64_t flag = 0; public: explicit PrimeNumberGenerator(int start) { this->number_start = start; } int GetNextPrime() { int64_t start = this->number_start; int64_t tmp_flag = 0; int64_t finish = MAX_SIZE/2; bit_arr arr; for (int i{3}; i <= finish; ++i) { if (!arr.test(i)) { if (i >= start) { if (tmp_flag == this->flag) { this->flag++; return i; } else { tmp_flag++; } } for (int j = i * 2; j <= finish; j += i) { arr.set(j); } } } return 0; } };