All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Pell's Equation (Posted on 2023-10-21) Difficulty: 3 of 5
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.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts Faster program, two solutions Comment 2 of 2 |
The second solution is when Y=1.  So indeed the solution is unique when X,Y,N > 1

(X,Y,N) = (458, 1, 209763)
458^2 -  209763*1^2 = 1

(X,Y,N) = (9801, 364, 725)
9801^2 -  725*364^2 = 1

I did some analysis to see how many digits each of X, Y, and N can have and looped through X and Y values of the appropriate ranges.

Also made lookup dictionaries for squares.
--------------
x_2 = [i**2 for i in range(316, 31624)]
y_2 = [i**2 for i in range(1,10000)]

x_dict = {xsqrd: int(round(xsqrd**.5)) for xsqrd in x_2}
y_dict = {ysqrd: int(round(ysqrd**.5)) for ysqrd in y_2}

solutions = []

for ysquared in y_2:
    for xsquared in x_2:
        calc = (xsquared - 1) / ysquared
        if calc%1 == 0:
            n = int(calc)
            x = x_dict[xsquared]
            y = y_dict[ysquared]
            digits = str(x)+str(y)+str(n)
            if len(digits) != 10:
                continue
            if len(set(digits)) == 10:
                print(x,y,n, x**2 - n*y**2)
                solutions.append([x,y,n])

print()
for s in solutions:
    print(s, s[0]**2 - s[2]*s[1]**2)

OUTPUT:  
[458, 1, 209763] 1
[9801, 364, 725] 1

Edited on April 6, 2024, 11:13 am
  Posted by Larry on 2024-04-06 11:10:50

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information