Skip to content

Commit

Permalink
Update primes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
teschlg committed Oct 31, 2024
1 parent 3c278ba commit 561234f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion kryptools/primes.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,22 @@ def is_prime(n: int, trialdivision: bool = True) -> bool:
307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397):
if n % p == 0:
return n == p
if n < 18446744073709551616: # https://miller-rabin.appspot.com
if n < 341531: # https://miller-rabin.appspot.com
return miller_rabin_test(n, [9345883071009581737])
if n < 885594169:
return miller_rabin_test(n, [725270293939359937, 3569819667048198375])
if n < 350269456337:
return miller_rabin_test(n, [4230279247111683200, 14694767155120705706, 16641139526367750375])
if n < 55245642489451:
return miller_rabin_test(n, [2, 141889084524735, 1199124725622454117, 11096072698276303650])
if n < 7999252175582851:
return miller_rabin_test(n, [2, 4130806001517, 149795463772692060, 186635894390467037, 3967304179347715805])
if n < 585226005592931977:
return miller_rabin_test(n, [2, 123635709730000, 9233062284813009, 43835965440333360, 761179012939631437, 1263739024124850375])
if n < 18446744073709551616:
return miller_rabin_test(n, [2, 325, 9375, 28178, 450775, 9780504, 1795265022])
if n < 318665857834031151167461:
return miller_rabin_test(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37])
if n < 3317044064679887385961981:
return miller_rabin_test(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41])
return miller_rabin_test(n, [2]) and lucas_test(n) # Baillie–PSW primality test
Expand Down

0 comments on commit 561234f

Please sign in to comment.