So there's a whole story centered around "Fermat's Last Principle" which states that for any integers $a$, $b$, and $c$, there
is no way of sastisfying $a^n+b^n=c^n$, where $n$ is an integer power other than $1$ or $2$. We know $1$ works, as this is simple arithmetic, and
$2$ works, because that is is the Pythagorean Theorem. What about 3? 4? 10? Any other number? Yes, this is one of those wild mathematical puzzles that went unsolved
for 350 years, until Andrew Wiles proved it in 1995.
This lesson will allow you to practice with for-loops and testing if you can find integers that satisfy Fermat's Principle. In
this case, since we need a whole sequence of a's, b's, and c's, we'll use 3 for-loops, one inside of another. These for-loops
are referred to as "nested." Check out the stuctures below. The for loop that generates our c's in inside of the one that generates our
b's, which is inside of the one that generates our a's.
We'll only give you enough server time to test small ranges of a,b, and c (like 50 numbers each), but go ahead! See if you
can prove Fermat's Last Theorem! Just look at the upbeat print statement in the if body. Think it will
ever get used?
Now you try. Choose n, ranges in all 3 for-loops, and an if-statemnet condition that will test Fermat's Principle.
Type your code here:
See your results here:
This code will not run! First choose an $n$ that you wish to work with. Then choose ranges for the a, b, and c for-loops.
Lastly, what if condition will you use to test Fermat's Theorem, given the current values of a, b, and c?
Share your code
Show a friend, family member, or teacher what you've done!