Fruitful Functions

 

Fermat was right!!!

In this assignment we had to create a function named check_fermat that takes four parameters—a, b, c and n and that checks to see if Fermat’s theorem holds. If n is greater than 2 and it turns out to be true that an + bn = cn the program should print, “Fermat was right!” Otherwise the program should print, “No, that doesn’t work.” This assignment was so we could get more knowledge about the chapter read and use that to make sure we had clear understanding of the topic.

fruitful-1

Code

fruitful-7

# 1 Fermat was Right!

fruitful-3

# 2 Fermat was Right!

fruitful-4

# 3 No, that doesn’t work.

fruitful-5

# 4 No, that doesn’t work.

Explanation:

While doing this assignment i encountered many problems. First I was not able to get any input value at all. We had to make sure that when run we got “Fermat was right!” in return. the input lets the user use any numbers and get the results. It was still difficult but I had help from a classmate. The ending results of the code are in the pictures.

By: Simran Sandhu