Computer Science, asked by iamsagar73, 5 months ago

Write a program to display all Pythagorean Triplets from 1 to 100. Three natural numbers a, b, c are said to be Pythagorean Triplet if a^2+b^2 = c^2 or b^2+c^2=a^2 or c^2+a^2=b^2​

Answers

Answered by BrainlyProgrammer
8

Bro, assuming it is Java coding

The best and easiest way to find pythagorien tripplet is that....

Take a no. 3

square it... u will get 9

divide it by 2...u will get 4.5

now b=Math.floor(4.5)

c=Math.ceil(4.5)

And hence u found it

Now comes the coding which is based on above explaination...

_______

int a, b, c;

for(I=1;I<=100;I++)

{

a=I;

b=(int) Math.floor(Math.pow(a,2)/2);

c=(int) Math.ceil(Math.pow(a,2)/2);

if ((Math.pow(a,2)+Math.pow(b,2))==(Math.pow(c,2)))

System. out. println("Pythagoreas Triplet:" +a+"^2"+b+"^2="+c+"^2);

}

______

if u don't understand my code...read the above explaination once

Hopes it helps u mark it brainliest

Similar questions