00:01
Hello and welcome.
00:02
We are looking at chapter 5, section 4, problem 21.
00:12
We're asked to prove the algorithm in exercise 7.
00:16
So real quickly, let me copy that down.
00:19
It's the product where n is a positive integer, and x is an integer.
00:41
If n equals 1, then we're returning x, else, returning n minus 1, sorry, the product of n minus 1 and x plus x.
01:07
So we want to prove this using induction.
01:11
So the first step with proving an induction is you need to prove the base case.
01:15
In this case, it's n equals 1.
01:17
So we want to prove that product 1 x equals product 1 equals product.
01:41
1x by definition is x and we know that 1 times x is x as well so that was pretty trivial usually the base case is pretty trivial the second step after we have the base case we want to show that the following statement is true so if the product of this time we'll do it a little differently than i usually do.
02:26
So n minus 1 x equals we'll just say x times n minus 1, then the product of nx equals n times x.
03:02
So the key to the second step of induction is we want to show that the previous step leads to the next step.
03:11
So we get to take this for granted.
03:14
And we need to use logical steps to get to this.
03:20
So we can say assume that product of n -1 and x equals x times n -minus 1.
03:36
So we get to just start by assuming that's true.
03:40
Now we need to figure out how can we get to here? how can we get to here? so what we could do is we could, if you look, this right hand side is equivalent to xn minus x...