Unprimeable numbers: Difference between revisions
m
C++ - renamed class
(→{{header|Factor}}: simplify) |
m (C++ - renamed class) |
||
Line 217:
<lang cpp>#include <iostream>
#include <cstdint>
#include "
typedef uint32_t integer;
Line 240:
// returns true if n unprimeable
bool unprimeable(const
if (sieve.is_prime(n))
return false;
Line 256:
int main() {
const integer limit = 10000000;
// print numbers with commas
Line 287:
}</lang>
Contents of
<lang cpp>#ifndef
#define
#include <algorithm>
Line 298:
* See https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.
*/
class
public:
explicit
bool is_prime(size_t) const;
private:
Line 311:
* @param limit the maximum integer that can be tested for primality
*/
inline
limit = std::max(size_t(3), limit);
is_prime_.resize(limit/2, true);
Line 331:
* @return true if the integer is prime
*/
inline bool
if (n == 2)
return true;
|