Enum LucasCheck

Source
pub enum LucasCheck {
    Strong,
    AlmostExtraStrong,
    ExtraStrong,
    LucasV,
}
Expand description

The checks to perform in the Lucas test.

Given the Lucas sequence built from some base (P, Q) (see LucasBase) up to the elements V(d), U(d), where d * 2^s == n - (D/n), d odd, and D = P^2 - 4Q, the checks are defined as follows:

Variants§

§

Strong

Introduced by Baillie & Wagstaff1. If either of the following is true:

  • any of V(d*2^r) == 0 for 0 <= r < s,
  • U(d) == 0,

report the number as prime.

If the base is SelfridgeBase, known false positives constitute OEIS:A2172552.

R. Baillie, S. S. Wagstaff, “Lucas pseudoprimes”, Math. Comp. 35 1391-1417 (1980), DOI: 10.2307/2006406, http://mpqs.free.fr/LucasPseudoprimes.pdf

§

AlmostExtraStrong

A LucasCheck::ExtraStrong without checking for U(d). That is, if either of the following is true:

  • any of V(d*2^r) == 0 for 0 <= r < s,
  • V(d) == ±2,

report the number as prime.

Note: the second condition is only checked if Q == 1, otherwise it is considered to be true.

If the base is BruteForceBase, some known false positives are listed by Jacobsen1.

Note: this option is intended for testing against known pseudoprimes; do not use unless you know what you are doing.

D. Jacobsen, “Pseudoprime Statistics, Tables, and Data”, http://ntheory.org/pseudoprimes.html


  1.  
§

ExtraStrong

Introduced by Mo1, and also described by Grantham2. If either of the following is true:

  • any of V(d*2^r) == 0 for 0 <= r < s,
  • U(d) == 0 and V(d) == ±2,

report the number as prime.

Note that this check only differs from LucasCheck::Strong if Q == 1.

If the base is BruteForceBase, known false positives constitute OEIS:A2177193.

Zhaiyu Mo, “Diophantine equations, Lucas sequences and pseudoprimes”, graduate thesis, University of Calgary, Calgary, AB (1993) DOI: 10.11575/PRISM/10820

J. Grantham, “Frobenius pseudoprimes”, Math. Comp. 70 873-891 (2001), DOI: 10.1090/S0025-5718-00-01197-2

§

LucasV

Introduced by Baillie et al1. If V(n+1) == 2 Q, report the number as prime.

If the base is AStarBase, some known false positives are provided by Baillie et al1.


  1. R. Baillie, A. Fiori, S. S. Wagstaff, “Strengthening the Baillie-PSW primality test”, Math. Comp. 90 1931-1955 (2021), DOI: 10.1090/mcom/3616 

Trait Implementations§

Source§

impl Clone for LucasCheck

Source§

fn clone(&self) -> LucasCheck

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LucasCheck

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LucasCheck

Source§

fn eq(&self, other: &LucasCheck) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for LucasCheck

Source§

impl Eq for LucasCheck

Source§

impl StructuralPartialEq for LucasCheck

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.