Determine all possible pairs of positive integers satisfying each of these conditions:
- The last digit of their sum is 5.
- Their difference is a prime number.
- Their product is a perfect square.
I have two sets of code below each of which generates the following output.
One program uses the above definitions, the other uses the set of primes ending in 3 or 7. The difference between the members of each pair is a prime ending in 3 or 7.
It appears, but I can't prove yet, that IF the sum of a pair ends in 5 AND their product is a square THEN not only is their difference a prime, but also a prime ending in 3 or 7.
Specifically, for all primes p ending in 3 or 7:
i = int((p**2 - 2*p + 1)/4)
j = int((p**2 + 2*p + 1)/4)
(i,j)
(1,4)
(9,16)
(36,49)
(64,81)
(121,144)
(324,361)
(441,484)
(529,576)
(676,729)
(1089,1156)
(1296,1369)
(1681,1764)
(2304,2401)
(2601,2704)
(2809,2916)
(3136,3249)
(3969,4096)
(4624,4761)
(6084,6241)
(6561,6724)
(6889,7056)
(7396,7569)
(9216,9409)
(9604,9801)
We see that each (i,j) pair is the perfect squares of adjacent integers (n^2, (n+1)^2).
The square root of the smaller of the two numbers forms this series:
1, 3, 6, 8, 11, 18, 21, 23, 26, 33, 36, 41, 48, 51, 53, 56, 63, 68, 78, 81, 83, 86, 96, 98, ... which is not in Sloane's oeis
Since prime numbers are part of the generating function that produces this series, it is unlikely that a simple algebraic definition will be found for this sequence.
Since the last digit of their sum is 5, look at (i+j)/5 which is always 1 mod 4; (or (i+j) is always 1 mod 20), but i+j is always of the form 2n^2 + 2n + 1, no surprise, this doesn't help.
Note j-i which is prime by definition always ends in 3 or 7. And, aha!, it appears that the sequence of j-i is EVERY prime that ends in 3 or 7.
So we can start with the sequence of all primes 'p' ending in 3 or 7.
Find 2 adjacent squares n^2 and (n+1)^2 whose difference is the odd number 2n+1 = p.
So n = (p-1)/2 ; i = (p^2 - 2*p + 1)/4
(n+1) = (p+1)/2 ; j = (p^2 + 2*p + 1)/4
And in fact if we run this code, we get the same output as the code below
-----
primes = [i for i in range(200) if isprime(i) and (i%10 == 3 or i%10 == 7)]
for p in primes:
i = int((p**2 - 2*p + 1)/4)
j = int((p**2 + 2*p + 1)/4)
print( '({},{})'.format(i,j) )
-----
big = 10000
solutions = []
smaller = []
for i in range(1,big+1):
for j in range(i,big):
if (i+j)%10 == 5:
if isprime(abs(j-i)):
if isSquare(i*j):
solutions.append((i,j))
smaller.append(int(i**.5))
print( '({},{})'.format(i,j) )
|
Posted by Larry
on 2023-01-21 11:00:28 |