kickerboy123
Technical User
I am learn java now, Can anyone give me a tip how to make a pythagorean triples by using Java ?
like using For or do.....while statement?
Thanks
Lai
like using For or do.....while statement?
Thanks
Lai
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[b]for[/b] ([b]int[/b] i=1;i<=[green][i]2006[/i][/green];i++)
[b]for[/b] ([b]int[/b] j=1;j<=i;j++)
[b]if[/b] (Math.sqrt(i*i+j*j)==Math.round(Math.sqrt(i*i+j*j)))
System.out.println(j+[i]", "[/i]+i+[i]", "[/i]+Math.sqrt(i*i+j*j));
for (int i=1;i<=2006;i++)
for (int j=1;j<=i;j++)
if (Math.sqrt(i*i+j*j)-Math.round(Math.sqrt(i*i+j*j))<0.00001)
System.out.println(j+", "+i+", "+Math.sqrt(i*i+j*j));
if ([red]Math.abs([/red]Math.sqrt(i*i+j*j)-Math.round(Math.sqrt(i*i+j*j))[red])[/red]<0.00001)
System.out.println(j+", "+i+", "+Math.sqrt(i*i+j*j));