⽰六祖,各组勾股数⽆重复
import math
n = 0
for a in range(1,49):
for b in range(a,49):
c = il(math.sqrt(a**2+b**2))
if c<50 and c**2 == a**2 + b**2:
if(n%6 == 0):
print("%2d,%2d,%2d"%(a,b,c),end='\t')
n+=1
n = 0
for a in range(1,49):
for b in range(a,49):
for c in range(b,50):
if a**2 + b**2 = c**2:
if n%6==0 :
print()
print("%2d,%2d,%2d"%(a,b,c),end=' ')
n += 1
记住我
发布评论