Trait nt_primes::traits::NTPrimality
source · [−]pub trait NTPrimality: NumberTheory + Sized {
fn is_standard(&self) -> bool;
fn sophie_safe(&self) -> Option<Self>;
fn delta(&self, delta: Self) -> Option<Self>;
fn nearest(&self) -> Self;
fn nearest_greater(&self) -> Option<Self>;
fn nearest_lesser(&self) -> Option<Self>;
fn nt_strength(&self) -> Option<i8>;
fn is_form(&self, scalar: Self, addend: Self) -> bool;
fn is_isolated(&self) -> bool;
}
Required methods
fn is_standard(&self) -> bool
fn is_standard(&self) -> bool
Checks if a number is a standard prime
fn sophie_safe(&self) -> Option<Self>
fn sophie_safe(&self) -> Option<Self>
Check if n is a sophie germain, returns Safe prime if true
```
let sophie = 1481u64;
let safe = sophie.unwrap();
assert_eq!(safe,2963)
Finds if number is prime, then returns either zero if no prime found at the distance or the prime. Returns None if self is not prime.
let start = 3u64;
let twin = start.delta(2).unwrap();
assert_eq!(5, twin);
Returns nearest prime to self. Only operates within bounds of datatype. Biases toward larger primes.
fn nearest_greater(&self) -> Option<Self>
fn nearest_greater(&self) -> Option<Self>
Returns nearest greater prime from self. Self is not necessarily a prime, will return None if value can’t be found in range of the integer type.
let point = Mpz::u_from_string("45431654658454164674896465").unwrap();
let prime = point.nearest_greater().unwrap();
assert_eq!("45431654658454164674896481", prime.to_string())
fn nearest_lesser(&self) -> Option<Self>
fn nearest_lesser(&self) -> Option<Self>
Returns nearest lesser prime from self. Self is not necessarily a prime
fn nt_strength(&self) -> Option<i8>
fn nt_strength(&self) -> Option<i8>
Number-theorectic strength. -1 for weak primes, 0 for balanced, 1 for strong. Returns None if it is not possible to evaluate in the datatype bounds.
Prime numbers of the form xn + k
let pythagorean = 17657u64;
assert_eq!(true, pythagorean.is_form(4u64,1u64))
fn is_isolated(&self) -> bool
fn is_isolated(&self) -> bool
Returns true if self-2 and self+2 are not prime, but self is.