Hello, everyone, welcome to this session.
So today we will solve one more problem with the help of the so the name of the problem is genetics.
OK, Jaeson, genetics.
Now, what is the problem?
The problem is very simple.
So given the value, let's say, the value of Kastari, so what we have to do, we have to calculate
the seeds.
We have to convert the sum of series.
Now, the series is very simple.
So this will be the series.
To the power to and this is truly the poverty because the value of K Street, so I will go so I will
reach here, OK, when I point to the poverty, basically, in short for a general key, for a general
CAYLUS, it is will look something like this when bought two plus two square.
Tokyo and so on, tell when point to the power game, minus one and then one upon the power.
OK, so we have to calculate the sum of the cities for a general.
OK, the value of K will be given by the user and this is how the cities will look like.
So we have to use recursion to solve this problem.
OK, so how we can use recursion to solve this problem.
So what we will do, we will break the cities into OK.
So this is basically to to the power zero.
OK, now we have a bigger problem.
So with the help of the equation, what we will do, we will give the smaller problem to the recursion.
So I will pick the cities from here.
So if this total series, if I call it --, OK, so if I'm calling this total series as dramatic.
So what will the series be called?
So what is the series?
So the series is nothing, but this is the sum game minus one.
OK, so the question will give me the answer for this series, OK, recursion, I believe recursion.
I believe the function recursion will give me the answer for the series.
And after getting the answer, what we will do, I have to calculate this part.
So this part is nothing, but it is just one divided by two, the power key so we can use the power
function here.
Power of truth, the power key.
OK, and that's how we will get our answer.
OK, so let us write the code now.
First of all, before writing the code, what would be the answer for this when the value of Kastari
so we are answered, this will be one plus one by two.
This is zero point five, one by four.
This will be zero point two five.
And then one by eight, so basically this will be zero point one, two five, so if he will add these
four times, we will get one point eight, seven five.
So basically our return type will be double.
OK, this will be a double offload.
It will not be an integer.
OK, now let us write the code and we will check.
We will run our code against the value of equals three.
OK.
So let's ride the gold.
So.
There will not be intelligence or there will be a double.
So they're trying to build a wall and let's say the name of the function is genetics, so -- what
it will take, it will take a number as argument.
OK, so first of all, best case, we have to think about the best case.
So if the value of care is zero, so what is the answer?
If the value of Kazue.
OK, so let's see again.
So if the value of Kizito is the value of Kasit over the cities, so the savings will be simply this
one.
OK, for gay couples, zero, our cities will be one plus one divided by.
No one understood the power.
OK, so this will be our city's for Khosro.
This is our cities, OK, four gateways, three, so I will go till three when the value of K zero,
I will go only this much.
OK.
Only one time when the earthquake was, you know, I have only one time, so this is nothing but one
by one.
So this is one.
OK, so this is our base case.
If the value of KS is zero, I would answer this one.
OK.
This is our base case.
So the value of Casey doing what I have to do, I have to return well, now what will do recursive case.
So the equation will give me the answer for the smaller problem.
OK, so I will return.
I will store down the variable so double, Smolan said.
Because the return type is so dramatic, some.
I will give give my innocent a dramatic some will give me the dramatic sum of game minus one times and
now the calculation part.
So the calculation part is very easy, would have to do I have to calculate one thing, so I will return
Smolan answer.
Plus now if we have to, do we have to calculate this part?
OK, this is our last digit.
So this is the last visit.
This is the last digit I have to calculate this last digit.
So what I will do, I will write one divided by.
True to the power, but this will be wrong because this is issue and this is in beta and digital opponent
T.J. will be an integer, but I want double value.
OK, so what I will do, I will write 1.0.
OK, so that I can get the answer as double, so I will write 1.0.
So developing integer will be the one only and then I'm using power function.
So that function takes two things as argument.
So I have to calculate the power.
OK.
We can see here I have to calculate the Bürki.
OK, so this will be our goal.
Very simple goal.
And now let us test our gold.
Let us call the some function and let the value of KS three and four.
Trevino's so should be one point eight seven five.
OK, let's try Neverfail.
So our answer is one point eight seven five zero gold is working fine, and if you want, we can also
we can also do that in our code.
We can draw the diagram.
So the value of Kastari.
OK, so she's not close to zero, I will calculate I will call the function for two, then I will call
the function for one, then I will call the function for zero.
So if the value of K zero, I am returning one.
So it will return one.
So basically, the small answer contains one, and then what I am doing, I am calculating, I am returning
small, sir, I am returning, Smolan said, which is one plus one divided by two to the basket case,
one only.
OK, so what?
I'm returning.
So this is basically.
One plus, this is zero point five, so basically one point five, so answer for a smaller answer is
one point five and then I imagine smaller surplus, this part.
So basically what I'm returning I'm returning one point five plus one divided by two squared because
the value of Kastel, so one divided by four when by four.
So what is one before.
So when Baffour is zero point two five.
So one point five zero point two five.
So one point five plus point two five, so this will be five seven one point seven five so small and
is one point seven five.
And then again, the value of Kastari, so small answer surplus one by eight and this will be one point
eight seven five.
OK.
So when say it is zero point one to five, so if I will add one point seven five and zero point one
to five, so this is five, seven, eight and one point eight seven five.
So this is how that is how we will get our answer will be one point eight, seven five.
OK, so I hope you understood this problem also.
OK, so that it will be readable.
And first we will write the code, then we will think of the diagram.
OK, then we will write a novel called First Write the Code and then frustrate the court with the help
of PMI and then draw the diagram.
OK, so I hope you understood this problem.
Also, if you have any doubt, you can definitely ask me.
OK, thank you.