00:01
Hello and welcome.
00:02
We are looking at chapter 5, section 4, problem 18.
00:08
We're asked to prove algorithm 1.
00:12
So let's real quick just copy down algorithm 1 so we know what we're proving.
00:20
So it's a procedure called factorial takes a non -negative integer n.
00:40
If n equals 0, then we return 1, else we return n times factorial of n minus 1.
01:03
So we want to prove this, and we're going to use induction to prove it.
01:11
So with induction, there's two steps.
01:14
There's the base case, basically proving this first step here.
01:21
So we want to show that, we want to show that factorial 0 equals 0 factorial.
01:39
So factorial 0 by definition, if n is 0, then the result is 1.
01:44
And it's a well -known fact that 0 factorial is 1 as well.
01:49
So the base case is proven.
01:53
And so with induction, next we want to show that we kind of want to, we set up our dominoes and we want to show that if you knock over one domino the rest of them fall.
02:02
So we want to prove the following statement.
02:06
We want to say we want to prove if factorial n equals n factorial, then factorial n plus 1 equals n plus 1 factorial.
02:42
And you could also solve this replacing this left -hand side with n -1 and n -1 factorial, and this right -hand side with n and n -factorial.
02:53
It might be easier, i don't know.
03:01
So with what we're doing, we start with the if part of this.
03:06
This we get to take for granted, and we want to use true mathematical steps, logical steps, to get to the then side.
03:13
That's how you prove by induction...