English | 简体中文
A Pythagorean triplet is a set of three natural numbers,
For example,
There exists exactly one Pythagorean triplet for which
Find the product
Answer: 31875000
for (long i = 1; i < 1000; i++) {
for (long j = 1; j < 1000 - i; j++) {
long base3 = 1000 - i - j;
if (base3 * base3 == i * i + j * j) {
return i * j * base3;
}
}
}
return 0;
Since there exists exactly one Pythagorean triplet, we just need to calculate the 2 condition(Pythagorean theorem and