Hey, guys, what's up?
So in this video, we will solve another industrial problem, one function.
So the problem is very simple.
We have to write a function, write a function.
To of.
NCR.
So what is NCR, so NZEI?
It was an factorial upon and minus Victoria and two of Victoria.
OK, so this is the form love finding NCAR.
So the value of N and art will be given by use it.
So how we can find ends here.
So we have to find first of all, we have to find and factorial.
Then we will find odd factorial.
And then we will find and minus our factory.
And then we will divide.
OK.
And how to find a factorial phone number.
We have sold.
We have.
We have seen it in the last radio.
OK, so the last radio was how to find fact Orlova number.
OK, so they destroyed the gold.
So let us name this filer's function, NTR Nazi Beebee.
So I would take and put two number and and ah.
Now, what do we do?
Let's make a variable answer, which is it goes to let's name the function as an S..
And it will take two will loose as input.
And and so NCAR is a function and what it will give me.
And it will give me the value of NCAR to see out answer.
Now let us implement NCAR function.
So they're done by I will be.
And because I have to return an integer value.
So end and see what it will take to number as input.
So end and and.
And what we have to do.
We have to redone.
Factory love and.
Divided by Victoria, Love and minus.
And to Victoria Love.
And now what we have to do.
We have to implement a function that will find the Victrola phone number, which we have done in the
last class.
So this was the code.
Let's cooperate.
And where's your typist?
So I'm calling function fact.
So it should be placed above NCAR.
OK.
So I think our code is ready.
So what I'm doing here is I am taking Tuvalu's as input and I'm calling the function ncar.
So NCAR function to the value of NCI equals and factorial divided by and minus factorial and two are
factorial.
OK.
So this function is calling.
Fact, function, vectorial function to find these factorial.
Okay, so how it works.
First of all, I was I was having Maine.
Men will call NCAR and see, I will call fact.
Three times it will qualify.
Two times, first four and then four and minus eight, then foot out.
So for the first time, let's say for N it will LoDo work and it will redonda value to NCEA.
So caustic would look something like this then and say, I will again call fact for calculating N minus
R, then after calculating and returning the value of and minus eight factorial, the NCAR function
will again call fact function.
So effect.
And it will be done differently.
Love.
Ah.
Now what will happen.
I will execute NCR so I have all the way loose.
I have value off and factorial and minus of victory.
Of victory.
Now I will have done so.
I will have done the answer to mean.
Now what men will do.
So the court was in town so it was NCAR and Gomaa and Main was printing the out answer.
So meanwhile, the words work and after it will hurt, return zero treatment.
Men will be bombed out and my stead becomes empty.
Okay, now this is my entire code.
Let's check.
So I suppose the of friend is five and the value of foresty some outproduce coming out to.
Then let's see whether my output is correct or not.
So I have to calculate five C three, which is five factorial upon five minus three factorial.
And do t factorial.
OK, so five factorial is one twenty two factorial and three factorial.
So when 20 were this two factorial, two were this two factorial.
Six.
So two sixty six then.
So I put this.
Ten.
OK.
So I'm out for this.
Correct.
Now, one more thing that I want to again clarify is.
This and this are they both are different from this end and decide.
Why?
Because their scopes are different.
So here, if you change the value of n supposed to and you will make ah, let's say three.
They will not be any effect on the values of an NDR.
OK.
Similarly, this answer variable and this answer very well, they are completely different because they
have different scope.
Now, one more time you can see reusability of function.
We are using the code.
OK, so this is the main advantage of using functions.
OK.
So if you have any doubt, feel free to ask.
Thank you.