human
Pythagorean Triplet with given sum | Python3 program to find Pythagorean Triplet of given sum ..
Considering triplets in sorted order . The value of first element in sorted triplet can be at - most n / 3..
The value of second element must be less than equal to n / 2.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to pythagorean Triplet with given sum and the other steps required.
 def pythagoreanTriplet ( n ) :
	for i in range ( 1 , int ( n / 3 ) + 1 ) :
		for j in range ( i + 1 , int ( n / 2 ) + 1 ) :
			k = n - i - j
			if ( i * i + j * j == k * k ) :
				print ( i , " , ▁ " , j , " , ▁ " , k , sep = " " )
				return
	print ( " No ▁ Triplet " )
n = 12
pythagoreanTriplet ( n )