Answer to Question #237500 in Python for jammu harish

Question #237500
L=int(input())
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)

What is the trick behind this problem



1
Expert's answer
2021-09-15T01:49:29-0400

This code prints number of Pythagorean triplets within the given range L and works fine.


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
APPROVED BY CLIENTS