Quick actions

cmd+k|ctrl+k

Navigation

Languages

problem 9

Snippet info

Language

Java

Visibility

public

Author

aditjain01

Created

2016-03-03T21:52:52Z

Updated

2016-03-03T21:52:52Z

public class Problem9 {
	
	public static int getProductOfPythagoreanTriplet(int sum) {
		int product = -1;
		for(int c = 5; c < sum; c++) {
			for (int b = 4; b < c; b++) {
				int a = sum - c - b;
				if((a < b) && (a*a + b*b) == (c*c)) {
					return a*b*c;
				}
			}
		}
		return product;
	}

	public static void main(String[] args) {
		System.out.println(getProductOfPythagoreanTriplet(1000));
	}
}
INFO