1234567891011121314151617181920212223242526272829303132 |
- from psimp import in_100, hund_div
- from lucas import LucasPrime, StrongLucasPrime
- from millerrabin import MillerRabin
-
-
- def BailliePSW(n):
- """Run Baillie-PSW probable prime test
- """
- if n < 2:
- return False
- if in_100(n):
- return True
- if hund_div(n) != 0:
- return False
- if MillerRabin(n, 2):
- return False
- return StrongLucasPrime(n)
-
-
- def BailliePSWWeak(n):
- """Run a weaker version of the Baillie-PSW probable prime test, using the
- weaker lucas test.
- """
- if n < 2:
- return False
- if in_100(n):
- return True
- if hund_div(n) != 0:
- return False
- if MillerRabin(n, 2):
- return False
- return LucasPrime(n)
|