一个Python程序,它将在指定的时间间隔内输出所有Pythogorean三元组。(a,b,c)由三个整数a1, n中具有斜率值(长度c)的所有毕达哥拉斯三元组。
n=int(input("Enter on upper bound> 10:"))
c=1
a=1
b=1
if (a**2) + (b**2) == (c**2):
print ( a, b, c)
while (a**2) + (b**2) != (c**2) and c<n :
c=c+1
while (a**2) + (b**2) != (c**2) and b<c:
b=b+1
while (a**2) + (b**2) != (c**2) and a<b:
a=a+1发布于 2016-02-18 11:38:41
interval = [20, 50]
a = interval[0]
while a <= interval[1]:
b = interval[0]
while b <= interval[1]:
c = interval[0]
while c <= interval[1]:
if (a**2 + b**2) == c**2:
print(a, b, c)
c += 1
b += 1
a += 1https://stackoverflow.com/questions/35472277
复制相似问题