# Function ladderz::pre_algebra::is_prime

source ·

    pub fn is_prime(n: u32) -> bool

Expand description

Checks if a positive integer `n` is a prime number.

A prime number is a positive integer greater than 1 that is not evenly divisible by any positive integer other than 1 and itself.

## Examples

    use ladderz::pre_algebra::is_prime;

    assert!(!is_prime(1)); // 1 is not a prime number
    assert!(is_prime(2)); // 2 is a prime number
    assert!(!is_prime(4)); // 4 is not a prime number
    assert!(is_prime(7)); // 7 is a prime number

## Note

This function returns `false` for values of `n` less than 2 because, by definition, prime numbers must be greater than 1.