def tuplePyth(n):
list_=[]
for x in range(1, n):
for y in range(x + 1, (n - x) // 2):
for z in range (y + 1, n - x - y):
if smallestTrip(x, y, z)==False:
list_.append([x,y,z])
print (list_)
def pythTrue(a,b,c):
(A,B,C) = (a*a,b*b,c*c)
if A + B == C or B + C == A or A + C == B:
return True
def smallestTrip(a,b,c):
if pythTrue(a,b,c) == True:
if (a+b+c)%12 == 0:
return True
else:
return False
smallestTrip
checks if x,y,z are multiples of the basic 3,4,5 right triangle.
The goal is to generate all possible pythagorean triplets the sum of which is less than an inputed sum, n.
(these triplets must NOT be multiples of the (3,4,5) triangle.)
Is the complexity here O(nnlogn)?