Pythagorean Triple

  • + 1 comment

    If one of the sides has odd value like a = 11, then the other side ‘b' has to be even, hypotenuse = h

    & a² + b² = h² => 11² = h² - b² => 121 = (h+b) (h-b) => 121 = 121 x 1 ( if a is odd, we take h- b = 1, & if a is even h-b is taken 2) Now, since h- b = 1 , so h & b are consecutive numbers. But, h+ b = 121 , so 2 consecutive numbers the sum of which is 121, can be found out by dividing (121 -1) by 2 . So, the consecutive numbers are 60 & 61 Hence pythagorean triplets will be 11, 60 & 61 ………………(1) & 61² = 11² + 60² => 3721 = 121 + 3600 ( verified) Now, if a = even number 14, then b = even , hypotenuse = h h² = 14² + b² => 196 = h² - b² = ( h+b) ( h- b) = 98 x 2 Here, b is obtained by dividing ( 98 -2) by 2 Hence, triplet has to be 14, 48 & 50 ………….(2) 50² = 14² + 48² => 2500 = 196 + 2304 = 2500 ( verified) => 196 = ( 50 + 48) ( 50 - 48)

    python 3:

    def pythagoreanTriple(a):
        if(a%2==0):
            b=((a**2)/4)-1
            c=b+2
        else:
            b=((a**2)-1)/2
            c=b+1
        return a,int(b),int(c)