Learn

Were you able to figure out that these sums created a pattern of 4, 9, 16, and 25, or n2? In fact, this turns out to be true for all of the positive odd integers: the sum of the first n odd integers does, in fact, equal n2.

In mathematical symbols, what we are saying is that for all positive integers n:

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

Induction has important applications in the computer science industry, specifically in quality assurance and case-testing. When working at any programming job, you will need to test your code for every case imaginable in order to minimize the number of errors that could occur when the product releases. A good way to case-test your code is to determine if any case creates some kind of error upon execution or compilation.

How does this idea relate to induction? We will see in the upcoming checkpoints that we need n to be a positive integer in order for our conjecture to work. To show this, we will define a number n to be nonnegative if n is an integer that is greater than or equal to zero and then we will suppose our conjecture is true for all nonnegative integers n. In other words, our new conjecture is this:

$\sum^n_{i=0} (2i-1) = n^2$

### Instructions

1.

Let’s see why 0 will not work for the new conjecture. First, suppose we substitute 0 for n in the expression:

$\sum^n_{i=0} 2i-1$

Simplify this by hand, then create a variable called a and set it equal to your result.

2.

Now substitute 0 for n in the expression:

$n^2$

Then create a variable named b and set it equal to your result.

3.

Lastly, use the == operator to write a Python script that prints whether or not a equals b.