Problem Solution: Special Pythagorean triplet(projecteuler.net)

Future Technology

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);
}
}
}

}

}

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s