Function large_primes::standard
source · pub fn standard(num: &BigUint) -> boolExpand description
Performs the standard primality test by checking for prime factors from 2 to the square root of the given number.
This function checks whether the provided number is prime by testing for prime factors in the range from 2
to the square root of the number (inclusive). It returns true if the number has no prime factors in that range,
indicating that it is prime.
§Arguments
num- A reference to aBigUintrepresenting the number to test for primality.
§Returns
trueifnumpasses the standard primality test (has no prime factors from 2 to sqrt(num)).falseifnumhas a prime factor in the specified range or ifnumis less than or equal to 1. Note that the function returnstruewhennumis 2, as it is the only even prime number.
§Examples
use num_bigint::BigUint;
let prime_number = BigUint::from(19u32);
assert!(standard(&prime_number));
let non_prime = BigUint::from(15u32);
assert!(!standard(&non_prime));