Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,22 +1,19 @@
import random
from random import randrange
# Copied from https://rosettacode.org/wiki/Miller-Rabin_primality_test#Python
def is_Prime(n):
def is_Prime(n: int):
"""
Miller-Rabin primality test.
A return value of False means n is certainly not prime. A return value of
True means n is very likely a prime.
"""
if n!=int(n):
return False
n=int(n)
#Miller-Rabin test for prime
if n==0 or n==1 or n==4 or n==6 or n==8 or n==9:
#Miller-Rabin test for primes
if n in [2,3,5,7]:
return True
elif n<10:
return False
if n==2 or n==3 or n==5 or n==7:
return True
s = 0
d = n-1
while d%2==0:
@ -33,7 +30,7 @@ def is_Prime(n):
return True
for i in range(8):#number of trials
a = random.randrange(2, n)
a = randrange(2, n)
if trial_composite(a):
return False
@ -63,15 +60,11 @@ def main():
print("First 50 Pierpont primes of the first kind:")
pp = pierpont(120, 80, True)
for i in range(50):
print("%8d " % pp[i], end="")
if (i - 9) % 10 == 0:
print("")
print("%8d " % pp[i], "\n"*((i - 9) % 10 == 0), end="")
print("First 50 Pierpont primes of the second kind:")
pp2 = pierpont(120, 80, False)
for i in range(50):
print ("%8d " % pp2[i], end="")
if (i - 9) % 10 == 0:
print("")
print("%8d " % pp2[i], "\n"*((i - 9) % 10 == 0), end="")
print("250th Pierpont prime of the first kind:", pp[249])
print("250th Pierpont prime of the second kind:", pp2[249])