Find positive integers X, Y and N satifying the Pell equation: X² - N*Y² = 1 such that X, Y and N together contain all of the decimal digits 0 to 9 exactly once.
Note: The solution is unique when X,Y,N > 1.
(X,Y,N) = (9801, 364, 725)
9801^2 - 725*364^2 = 1
program output: 9801 364 725
I have not ruled out other solutions, perhaps with N having fewer digits and X,Y having more than 4 digits.
-----------------
def issquare(n):
""" Input an integer, Returns True iff it is a perfect square. """
if round(n**0.5)**2 == n:
return True
else:
return False
big = 1000
for n in range(1,big):
for y in range(1,big):
xsquared = 1 + n*y**2
if issquare(xsquared):
x = int(xsquared**.5)
digits = str(x)+str(y)+str(n)
if len(digits) != 10:
continue
if len(set(digits)) == 10:
print(x, y, n)
|
Posted by Larry
on 2023-10-21 11:07:18 |