Problem Solution: Special Pythagorean triplet(projecteuler.net)
Problem Solution: Special Pythagorean triplet(projecteuler.net)
public class SpecialPythagoreanTriplet { public static void main(String[] args) { // TODO Auto-generated method stub long sum = 0, total = 1000; for (double a = 1; a <= total / 3; a++) { for (double b = 1; b <= total / 2; b++) { double c = total - a - b; double e = Math.pow(a, 2); double f = Math.pow(b, 2); double g = Math.pow(c, 2); sum = (long) (a * b * c); if (Math.pow(a, 2) + Math.pow(b, 2) == Math.pow(c, 2)) { System.out.println("a: " + a + " b: " + b + " c: " + c); System.out.println("e: " + e + " f: " + f + " g: " + g); System.out.println("Sum: " + sum); } } } } }

One thought on “Problem Solution: Special Pythagorean triplet(projecteuler.net)

Leave a Reply

Your email address will not be published. Required fields are marked *