1 Attachment(s)
Help: Pythagorean Triples
SOLVED. THANKS TO EVERYONE THAT HELPED.
when i set the max to 500, which is what i need to compute to, the program leaves out triples such as 3,4,5 and 5,12,13, but when i set the max to a smaller number such as 50, it includes those triples. i dont get whats wrong. and also, the order goes from least "a" to greatest "a" and i would like it to go from least hypotenuse("c") to greatest. plz help. i use blue j to write the code/make the programs. i included a screenshot of the code too.
Code:
import javax.swing.JOptionPane;
public class C5_17
{
public static void main()
{
int max=500;
for (int a=1;a<=max;a++)
{
for (int b=1;b<=max;b++)
{
for (int c=1;c<=max;c++)
{
if ((a*a)+(b*b)==(c*c))
if(a<b)
System.out.println(a+" "+b+" "+c);
}
}
}
}
}