#include #include #include class PrimeNumberGenerator { public: explicit PrimeNumberGenerator(int start) { this->last = start; } int GetNextPrime() { int n; (this->last > 1) ? n = this->last : n = ++this->last; int i = 2, j = 0; while (true) { if (i * i <= n && j != 1) { if (n % i == 0) { j = 1; i++; } else { i++; } } else if (j == 1) { n++; i = 2; j = 0; continue; } else { this->last = n + 1; return n; } } } int last; };