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

Home > Numbers
Sum of Three Squares (Posted on 2024-07-27) Difficulty: 3 of 5
Determine the smallest positive integer that can be expressed as the sum of three nonzero squares in five different ways.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 2 of 2 |
Assuming that the 3 squares need not be distinct.
The smallest is:
194 
[(1, 49, 144), (9, 16, 169), (9, 64, 121), (25, 25, 144), (49, 64, 81)]
-----------
from itertools import combinations_with_replacement
big = 15
sqs = [n**2 for n in range(1,big+1)]
sumof3squares = {}

for comb in combinations_with_replacement(sqs, 3):
    mysum = sum(comb)
    if mysum not in sumof3squares:
        sumof3squares[mysum] = [comb]
    else:
        sumof3squares[mysum].append(comb)

winners = []
for k,v in sumof3squares.items():
    if len(v) > 4:
        winners.append(k)

winners = sorted(winners)
print(winners[0], sumof3squares[winners[0]])

  Posted by Larry on 2024-07-27 11:42:59
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 (12)
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