Determine all possible triplet(s) of positive integers such that each of p*q-r, q*r-p, and r*p-q is a power of 2.
*** Adapted from a problem appearing in IMO 2015.
keeping to the convention of
p <= q <= r and similarly for the values
p q r the formula values
2 2 2 2 2 2
2 2 3 1 4 4
3 5 7 8 32 16
2 6 11 1 64 16
------
import math
ans = []
big = 200
for p in range(1,big):
for q in range(1,big):
for r in range(1,big):
x = p*q-r
if x < 1:
continue
y = q*r-p
if y < 1:
continue
z = r*p-q
if z < 1:
continue
if (math.log(x,2))%1 != 0:
continue
if (math.log(y,2))%1 != 0:
continue
if (math.log(z,2))%1 != 0:
continue
pqr = sorted([p,q,r])
xyz = sorted([x,y,z])
if pqr+xyz not in ans:
ans.append(pqr+xyz)
print (ans)
I also did a version checking if the log base 2 was very close to zero (within epsilon), but the results were the same.
I can't be sure larger numbers do not yield more solutions.
|
Posted by Larry
on 2023-04-15 13:39:55 |