diff options
Diffstat (limited to 'sieve_utils.cc')
-rw-r--r-- | sieve_utils.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sieve_utils.cc b/sieve_utils.cc new file mode 100644 index 0000000..51bdcf1 --- /dev/null +++ b/sieve_utils.cc @@ -0,0 +1,10 @@ +#include "sieve.hh" +#include <cmath> + +[[nodiscard]] bool isPrime(std::size_t x) { + for (size_t i = 2; i <= sqrt(x); ++i) + if (x % i == 0) { + return false; + } + return true; +} |