Lab Part 001

import math
def check_fermat (a,b,c,n):
if n>2 and math.pow(a,n)+ math.pow(b,n) == math.pow(c,n):
print(“Fermat was right”)
else:
print(“NO that doesn’t work”)

a=1
b=2
c=3
n=4

check_fermat(a,b,c,n)

 

 

Lab Part 002

import math
import sys
def check_fermat (a,b,c,n):
if n>2 and math.pow(a,n)+ math.pow(b,n) == math.pow(c,n):
print(“Fermat was right”)
else:
print(“NO that doesn’t work”)
print(“Input a”)
a=int(input())
print(“Input b”)
b=int(input())
print(“Input c”)
c=int(input())
print(“Input n”)
n=int(input())

check_fermat(a,b,c,n)

 

 

Extra (Using Random to Utilize Random Numbers to Verify Fermat’s Last Theorem)

 

import math
import random

def check_fermat (a,b,c,n):
if n>2:
if(math.pow(a,n) + math.pow(b,n) == math.pow(c,n)):
print (“Fermat was right”)
print(” The values are”,a,” “,b,” “,c,” “,n)
else:
print(“Test Values are “,a,” “,b,” “,c,” “,n)
print (“No that doesn’t work”)
else:
print(“Please input a higher value for n”)

def check():
check_fermat(random.randint(1,100), random.randint(1,100), random.randint(1,100),random.randint(1,100))

def test_values():
check()
check()
check()
test_values()