So I need help calculating Pythagorean Triples, basically I want the output to look like this:
3 4 5
5 12 13
6 8 10
7 24 25
ETC.
I need help with the calculation portion and to ensure that I do not have duplicates (i.e. 5 12 13 and 12 5 13).
Thoughts? Can someone lead me in the right direction?
Here is my code that I have so far:
package cs520.hw1;
public class Triples {
public static void main(String[] args)
{
int x1, x2, x3;
for(x1 = 1; x1 < 100; x1++)
{
for(x2 = 1; x2 < 100; x2++)
{
for(x3 = 1; x3 < 100; x3++)
{
int a= x1, b=x2, c=x3;
if((Math.sqrt(a) + Math.sqrt(b)) == Math.sqrt(c))
{
if(a < b)
{
System.out.println(x1 +" "+ x2 +" "+ x3);
}
}
}
}
}
}
}