Fix bug in isProbablyPrime for small numbers
Fix bug in isProbablyPrime where too many iterations were specified for numbers less than 100 Add clause to isProbablyPrime to use hardcoded values <= 2903
This commit is contained in:
parent
0cec622ddf
commit
345f4cd141
@ -38,7 +38,8 @@ import Data.Bits
|
|||||||
isProbablyPrime :: Integer -> Bool
|
isProbablyPrime :: Integer -> Bool
|
||||||
isProbablyPrime !n
|
isProbablyPrime !n
|
||||||
| any (\p -> p `divides` n) (filter (< n) firstPrimes) = False
|
| any (\p -> p `divides` n) (filter (< n) firstPrimes) = False
|
||||||
| primalityTestFermat 50 (n`div`2) n = primalityTestMillerRabin 30 n
|
| n >= 2 && n <= 2903 = True
|
||||||
|
| primalityTestFermat 50 (n `div` 2) n = primalityTestMillerRabin 30 n
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
-- | generate a prime number of the required bitsize (i.e. in the range
|
-- | generate a prime number of the required bitsize (i.e. in the range
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user