const_primes

Function is_prime

Source
pub const fn is_prime(n: u64) -> bool
Expand description

Returns whether n is prime.

Does trial division with a small wheel up to log2(n) and then uses a deterministic Miller-Rabin primality test.

If the fast_test feature is enabled this function instead calls machine_prime::is_prime with the small feature.

ยงExample

Basic usage:

const CHECK: bool = is_prime(18_446_744_073_709_551_557);
assert!(CHECK);