Learn

We saw in the previous exercise an example of testing our code to discover faulty cases. We can now properly define the statement we found in Exercise 1: For any positive integer n, the sum of all of the odd integers up to and including n is equal to n2. In other words:

i=1n(2i1)=n2\sum^n_{i=1} (2i-1) = n^2

How do we go about proving such a statement is really true for any positive integer n? We will use the principle of mathematical induction, the formal definition of which will be developed throughout these next couple of exercises.

The first step in any induction proof is to identify the base case (the smallest possible case for which this statement is true). For instance, suppose you wanted to show for all positive integers x that x is at most x2, or

xx2x \leq x^2

Since our cases are all of the positive integers, our base case (the smallest case) for this example is the smallest possible integer. That happens to be 1, and we can show that 1 <= 1**2 quite easily because 1 = 1**2. Therefore, we have proven the base case for this conjecture. The upcoming checkpoint will ask you to find the base case for the statement

i=1n(2i1)=n2,\sum^n_{i=1} (2i-1) = n^2,

which we established earlier in this narrative.

Instructions

1.

Think about the smallest possible case which proves our statement as described in the narrative. When you think you have the answer, create a variable called k and set it equal to that number in the code editor.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?