Congratulations, we have completed the first step to our induction proof! Next comes the inductive step, which begins with our definition of the induction hypothesis. The induction hypothesis supposes that our statement is true for some integer k
, with the caveat that k
must exceed the number set as the base case.
Recall that we supposed that for any positive integer n
:
Using the definition of induction hypothesis as well as the fact that we defined the base case as k = 1
in the previous exercise, we can reword this conjecture to say this:
For some integer k
in which k > 1
:
We will use Python to code this hypothesis through the upcoming checkpoints. For convenience, we will set the variable k
equal to nine.
Instructions
First, create a variable called s
and set it equal to the default value of 0
.
Next, set s
to store the sum of first i
odd integers, where i
is a value starting at 1
and increments each iteration until the first k
odd integers have been added together. In other words, rewrite:
using a Python script. Print s
to ensure that the code worked properly.
Finally, use the ==
comparison operator to write a Python script that prints whether or not s
really does equal k**2
.