Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Wagstaff-primes/Python/wagstaff-primes.py
Normal file
18
Task/Wagstaff-primes/Python/wagstaff-primes.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
""" Rosetta code Wagstaff_primes task """
|
||||
|
||||
from sympy import isprime
|
||||
|
||||
def wagstaff(N):
|
||||
""" find first N Wagstaff primes """
|
||||
pri, wcount = 1, 0
|
||||
while wcount < N:
|
||||
pri += 2
|
||||
if isprime(pri):
|
||||
wag = (2**pri + 1) // 3
|
||||
if isprime(wag):
|
||||
wcount += 1
|
||||
print(f'{wcount: 3}: {pri: 5} => ',
|
||||
f'{wag:,}' if wcount < 11 else f'[{len(str(wag))} digit number]')
|
||||
|
||||
|
||||
wagstaff(24)
|
||||
Loading…
Add table
Add a link
Reference in a new issue