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

Home > Numbers
Make it solvable (Posted on 2005-05-05) Difficulty: 4 of 5
a, b, and x are positive integers such that

sqrt(a) + sqrt(b) = sqrt(x)

How many possible values of x less than or equal to 1000 are there?

See The Solution Submitted by Jer    
Rating: 3.6667 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution Comment 18 of 18 |
I found 392 values of x and 961 values of {a,b,x} where a <= b.

In the line below marked in boldface, I initially just had 
if x > 1000  but this introduced a rounding error where I missed 2 values of {a,b,x} although the number of x values was unchanged.

ans = []
eps = .0000001
for a in range(1, 1000):
    sqrt_a = a ** .5
    for b in range(a, 1000):
        sqrt_b = b ** .5
        x = (sqrt_a + sqrt_b)**2
        if x > 1000 + eps:
            continue
        frac = x%1
        if frac < eps:
            x = x//1
            ans.append([a,b,int(x)])
        if (1-frac) < eps:
            x = x//1 + 1
            ans.append([a,b,int(x)])

xvalues = []
for a in ans:
    if a[2] not in xvalues:
        xvalues.append(a[2])
print (len(ans))
print (len(xvalues))

  Posted by Larry on 2023-03-25 09:25:31
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 (7)
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