# Write a program to find the product of abc if there exists exactly one Pythagorean triple for which a + b + c = 1000. Hint: A Pythagorean triple is a set of three positive numbers, a < b < c, for which, a^2 + b^2 = c^2. For example, 3^2 + 4^2 = 5^2

**Updated:**Aug. 15, 2022 —

**Training Time:**1 Minute

Overseen by: Archangel Macsika

All Training Resources

Scroll for more menu list

**Topic:**Generic - Java Programming

**Difficulty:** Easy.

**Companies who previously asked this:** -.

**Objective:** Write a program to find the product of a Pythagorean triple 'abc' if there exists exactly one Pythagorean triple for which a + b + c = 1000. Hint: A Pythagorean triple is a set of three positive integers, a < b < c, for which, a^{2} + b^{2} = c^{2}. For example,

3^{2} + 4^{2} = 5^{2}

9 + 16 = 25.

**Input:** None.

**Expected Output:** Find out.

### Sikademy Solution

```
package sikademy;
/**
*
* @author Archangel Macsika
*/
import java.util.logging.Logger;
// This class finds the value of abc.
public class PythagoreanTriplets {
private static final Logger LOG = Logger.getLogger(ProductOfFiveDigits.class.getName());
public static void main(String[] args) {
LOG.info("Into main");
int a = 0;
int b = 0;
int c = 0;
int sum = 1000;
boolean solved = false;
for(a=1; a<500 && !solved; a++){
for(b=1; b < 500 && !solved; b++){
c = sum - a - b;
if((a * a) + (b * b) == c * c){
solved = true;
LOG.info("The numbers are " + a + " " + b + " " + c + " " + " and the product is : " + (a * b * c));
}
}
}
}
}
```