In the previous example, we calculated the complexity of the iterative method.
So now let's do it with the recursive method.
Here.
Suppose we need to calculate the fraction of a certain number, for instance, six, which will produce
here.
Actually, let's make this here for example, we want to create something like that six fractional number
six and which will produce the six fraction equals here.
Six, multiply by five, multiply by four, multiply by three, two and one, which is equal to 27 720.
So for this purpose we can use the recursive method.
So which is we're going to write this in this lecture.
So here let's actually create a new method named Integer Fractional.
Or factorial, factorial.
And here we this will get a new integer n here.
And now if our.
N is equal to one, then return one.
Signs here.
And, uh, else, if it's not uh, executed, then return and multiply by a fractional fraction.
Factorial.
N minus one.
That's our function.
So for the preceding function, we can calculate the complexity of this similarly to how we did in iterative
methods.
So which is f n equals n times.
It depends how much data is being processed, which the data is n here.
So we can use constants, for instance, C to calculate a lower bound and upper bound here.
So now we're going to in next lecture, we're going to use the amortized analysis for this purpose.
I'm waiting you in the next lecture.