This program proves whether or not Fermat’s Last Theorem is true. His theorem states that no three positive integers a, b and c can satisfy the equation an + bn = cn for any integer value of n greater than two. The program asks you for the values of a, b, c and n. If the output does not equal to each other, then the theorem is correct. If the equation does equal to each other, then Fermat is wrong.
print(‘No 3 positive integers a,b and c can satisfy the equation a^n + b^n = c^n for any integer value of n greater than two.’)
a = int(input(‘What is your a? ‘))
b = int(input(‘What is your b? ‘))
c = int(input(‘What is your c? ‘))
n = int(input(‘What is your n? ‘))
def check_fermant(a, b, c, n):
if n < 2:
print(‘n should be greater than 2!’)
elif n > 2 and a**n + b**n != c*n:
print(‘Fermat was right!’)
else:
print(‘Holy Smokes, Fermat was wrong!’)
print(a**n + b**n, ” = “, c**n)
check_fermant(a, b, c, n)