练习5.3。费马的最后定理说没有正整数a,b和c这样
a ^ n + b ^ n = c ^ n
任何大于2的n值。
a ^ n + b ^ n = c ^ n
程序应该打印出来,“圣烟,费马错了!”否则程序应该打印出来,“不,那不行。”答案 0 :(得分:1)
def check_fermat(a, b, c, n):
if n > 2 and (a**n + b**n == c**n):
print("Holy smokes, Fermat was wrong!")
else:
print("No, that doesn’t work.")
def check_numbers():
a = int(input("Choose a number for a: "))
b = int(input("Choose a number for b: "))
c = int(input("Choose a number for c: "))
n = int(input("Choose a number for n: "))
return check_fermat(a, b, c, n)
check_numbers()
可能总会返回“不,那不行”....