Copyright | (c) 2011 Daniel Fischer 2017-2018 Andrew Lelechenko |
---|---|
License | MIT |
Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Jacobi symbol is a generalization of the Legendre symbol, useful for primality testing and integer factorization.
Synopsis
- data JacobiSymbol
- jacobi :: (Integral a, Bits a) => a -> a -> JacobiSymbol
Documentation
data JacobiSymbol Source #
Represents three possible values of Jacobi symbol.
Instances
jacobi :: (Integral a, Bits a) => a -> a -> JacobiSymbol Source #
Jacobi symbol of two arguments. The lower argument ("denominator") must be odd and positive, this condition is checked.
If arguments have a common factor, the result
is Zero
, otherwise it is MinusOne
or One
.
>>>
jacobi 1001 9911
Zero -- arguments have a common factor 11>>>
jacobi 1001 9907
MinusOne