triple pythagorean

This commit is contained in:
Johan Alexander López Loaiza 2023-10-24 23:03:32 -05:00
parent aa3683e056
commit 83e911a8a3
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,12 @@
number = int(input("Ingrese un número: "))
triple = []
for h in range(1, number + 1):
for a in range(1, number + 1):
for b in range(1, number + 1):
if h**2 == (a**2) + (b**2):
triple.append(h)
triple.append(a)
triple.append(b)
print("Tripleta pitagórica: ", triple)
triple.clear()

View File

@ -0,0 +1,11 @@
def triplePythagorean(number):
triple = []
for h in range(1, number + 1):
for a in range(1, number + 1):
for b in range(1, number + 1):
if h**2 == (a**2) + (b**2):
triple.append(h)
triple.append(a)
triple.append(b)
return triple