All right, so let's implement our recursive factorial function.
So we will say cargo, new recursion.
We'll go into recursion.
And now we will open up our main address.
So to keep it similar to how we talked about it in the previous lecture, we will make our own function
called fact and we'll make our argument a i 32 num and we want to return an I 32 as well.
All right.
So we have a base case that we can look for in here and we want to make sure that num is greater than
one, because if it's not greater than one, well then there's nothing else to do.
So we can just flat out return one.
Otherwise we want to return num times, fact of num minus one.
And if you remember we do this because we have in factorial is equal to n times n minus one factorial.
And we establish that this is equal to calling our factorial of n function and having it call itself
again.
So the recursion happens here of the result of n times factorial of n minus one, and that's exactly
what we're doing.
So we're passing in our parameter or our argument and we're saying we want to return that number times
the factorial of num minus one.
So to test this, we can come down here and we can print line
and we just want to print out the factorial of five.
And if we go run this, we will see that we have 120, which is correct.
That is five times four times three times two, five times four, 20 times three, 60 times two 120.
And that's all there is to it, to recursion.
Right.
So it's a it's a pretty simple concept and we want to make sure that.
For it to be recursion that we just have to call ourselves.
So we're going to look at a couple more examples of recursion.
That way you get really comfortable doing it so that as we use it later on in this course, you are
fully confident in your ability to understand what is what is going on.