Added 51 description and first observrations
This commit is contained in:
35
51/main.py
Normal file
35
51/main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
'''
|
||||
By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.
|
||||
|
||||
By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003, 56113, 56333, 56443, 56663, 56773, and 56993. Consequently 56003, being the first member of this family, is the smallest prime with this property.
|
||||
|
||||
Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime value family.
|
||||
'''
|
||||
|
||||
import numpy as np
|
||||
import math
|
||||
|
||||
def sieve(n):
|
||||
assert n > 1
|
||||
|
||||
ns = [True] * n
|
||||
|
||||
for i in range(2, math.ceil(np.sqrt(n))):
|
||||
if ns[i]:
|
||||
j = pow(i, 2)
|
||||
|
||||
while j < n:
|
||||
ns[j] = False
|
||||
j = j + i
|
||||
|
||||
return [i for i,val in enumerate(ns) if val][2:]
|
||||
|
||||
def main():
|
||||
print("Hello this is Patrick")
|
||||
|
||||
primes = sieve(1000000)
|
||||
|
||||
# So instead of going past all number families and see if they are prime I think it's better to look for families in the primes
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user