isPrime

Checks if a number is prime.

bool
isPrime
(
T
)
(
T n
)
if (
isIntegral!T
)

Return Value

Type: bool

true if n is prime.

Examples

assert(isPrime(2));
assert(isPrime(3));
assert(isPrime(5));
assert(isPrime(7));
assert(isPrime(199UL));
assert(isPrime(104_729)); // 10,000th prime.

assert(!isPrime(-199));
assert(!isPrime(-1));
assert(!isPrime(1)); // 1 is not a prime number: https://primes.utm.edu/notes/faq/one.html
assert(!isPrime(4));

Meta