完美立方

N = input("输入数字:")
N = int(N)
m = 0
for a in range(2, N + 1, 1):
    for b in range(2, a):
        for c in range(b + 1, a):
            for d in range(c + 1, a):
                if (a ** 3 == b ** 3 + c ** 3 + d ** 3):
                    m += 1
                    print("{0}^3 = {1}^3 + {2}^3 + {3}^3".format(a, b, c, d))
print("计算次数:" + str(m))

 

点赞