Wednesday, January 16, 2008

PythaGorian Triplets

Like 5,4,3 are Pythagorian Triplets this programs Finds all

import java.io.*;
class triplet

{
public static void main()
{
int i,j,k;
for(i=1;i<=10;i++)
{
for(j=i+1;j<10;j++)
{
for(k=j+1;k<10;k++)
{
if((i*i)+(j*j)==(k*k))
{
System.out.println(i+" "+j+"and"+k+"are pyth. triplets");
}
}
}
}
}
}

No comments: