A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a^2 + b^2 = c^2
For example,
3^2 + 4^2 = 9 + 16 = 5^2 = 25.
There exists exactly one Pythagorean triplet for which a + b + c = N (the input).
Find the product abc.
Solution Stats
Problem Comments
8 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers1385
Suggested Problems
-
2599 Solvers
-
1247 Solvers
-
Remove the small words from a list of words.
1560 Solvers
-
Project Euler: Problem 5, Smallest multiple
1650 Solvers
-
946 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The description should be 9 + 16 = 5^2 and not 9+16 = 2^5 ?
Thanks Aurelien! Fixed it.
This is an interesting problem. Apparently everyone (including me) had to solve it by a basic brute force method with oly very slight variations. I did manage to use my MATLAB copy to use solve from the symbolic toolbox to get the answers, but the version of MATLAB on which Cody runs doesn't have access to a license for the symbolic toolbox.
@ Doug Hall, I have solved all the problems in the series. However, I have not received the badge and the associated scores on completion of the series. Can you please help me with this?
Wow, all the triangles are in the ratio of 8:15:17? Pretty huge oversight.
People have realized that all test cases are based on the primitive Pythagorean triplet (8, 15, 17) and the solutions are full of hacks. This is quite annoying as one cannot compare one's solution with other valid ones.
Test suite has been updated with additional test cases and leading solutions have been rescored.
Am I missing something, or are the problems with some of the test cases?
For test case 7:
x = 240
y_correct = 48e4
15^2 + 112^2 = 225 + 12544 = 12769 = 113^2
15 + 112 + 113 = 240, so this satisfies the requirement.
15 * 112 * 113 = 189840, which does not match the expected answer.
Similarly for test case 8:
x = 90
y_correct = 21060
9^2 + 40^2 = 81 + 1600 = 1681 = 41^2
9 + 40 + 41 = 90, so this satisfies the requirement.
9 * 40 * 41 = 14760 which does not match the expected answer.