00:01
Hello, so here we have a program to calculate the factorial of a number n in a recursive way.
00:09
And first we need to check whether it's correct.
00:12
So one way to do this is we can walk through the program to see what it does.
00:16
So for example, i'm going to call site of 3.
00:22
And i'm going to see that n equals 0, so it will return n, which is 3 times factorial of 2.
00:32
So we call it again factorial 2 and equals 0 no so this will return 2 times factorial of 1 1 equals 0 so it will return 1 times factorial of 0 0 so this will return 1 0 so this will return 1 and the final result will be 3 times 2 times 1 times 1, which is equal to the factorial of 3.
01:03
So the program is indeed correct.
01:07
Now we need to design a non -facorceive version of this program.
01:15
So let's start by defining our function with the same attention as in the example code.
01:22
Factorial of int, n...