Determine all pairs of prime numbers p and q less than 100, such that the following five numbers:
p+6, p+10, q+4, q+10, p+q+1
are all prime numbers.
[p, q] = [7, 3], [13, 3], [37, 3], [97, 3]
If p were 1 mod 3, p+10 would be divisible by 3 and not prime.
If p were 0 mod 3, p+6 would be divisible by 3 and not prime.
So p is always 1 mod 3 (and odd, thus 1 mod 6).
If q could be 2 mod 3 then q+4 and q+10 would be divisible by 3 and not prime.
But if q could be 1 mod 3, then p+q+1 would be divisible by 3 and not prime.
So q must be 0 mod 3, and the only such prime is 3 itself.
Thus q = 3.
-------
big = 100
primes = [n for n in range(big) if isprime(n)]
bigpms = primes + [n for n in range(big, 2*big) if isprime(n)]
ans = []
q=3
for p in primes:
if p + 6 not in bigpms:
continue
if p + 10 not in bigpms:
continue
if q + 4 not in bigpms:
continue
if q + 10 not in bigpms:
continue
if p + q + 1 not in bigpms:
continue
ans.append([p,q])
print(ans)
|
Posted by Larry
on 2024-07-01 17:14:58 |