Answer to Question #292913 in Python for gayathri

Question #292913

A pythagorean triplet is a set of three integers a, b and c such that a**2+b**2=c**2.in the given limit L, find the number of pythagorean triplets R that can be formed (such that a<b<c).


1
Expert's answer
2022-02-03T08:39:11-0500
L=int(input("Enter a limit: "))
count=0
for a in range(1,L-1):
    for b in range(a+1,L):
        for c in range(b+1,L+1):
            x=a*a
            y=b*b
            z=c*c
            if (x+y==z):
                count+=1


print(count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS