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
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:
Let’s see why 0 will not work for the new conjecture. First, suppose we substitute 0 for n in the expression:
Simplify this by hand, then create a variable called
a and set it equal to your result.
Now substitute 0 for n in the expression:
Then create a variable named
b and set it equal to your result.
Lastly, use the
== operator to write a Python script that prints whether or not