HaskellForMaths-0.4.3: Combinatorics, group theory, commutative algebra, non-commutative algebra

Safe HaskellSafe-Infered



A module providing functions to test for primality, and find next and previous primes.



primes :: [Integer]Source

A (lazy) list of the primes

isStrongPseudoPrime' :: (Integral a1, Integral a) => a1 -> (Int, a) -> a1 -> BoolSource

split2s :: (Integral t1, Num t) => t -> t1 -> (t, t1)Source

power_mod :: (Integral a1, Integral a) => a -> a1 -> a -> aSource

isPrime :: Integer -> BoolSource

Is this number prime? The algorithm consists of using trial division to test for very small factors, followed if necessary by the Miller-Rabin probabilistic test.

prevPrime :: Integer -> IntegerSource

Given n, prevPrime n returns the greatest p, p < n, such that p is prime

nextPrime :: Integer -> IntegerSource

Given n, nextPrime n returns the least p, p > n, such that p is prime