Project Euler Homework
|
Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. More...
#include <iostream>
Go to the source code of this file.
Functions | |
int | main () |
Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.
A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc.
Definition in file 009.cpp.
int main | ( | ) |
All possible solution of Pythagorean triplet are: , , and for all positive integer m, n where m>n. Therefore
Upper limit of m:
There are 21 possible values of m, so possible solutions of .
Since and , . i.e. m,n are not multiple of 3, so and m is a factor of 500.