Hi this is rings in the heart.
And welcome to the next VUDU of functions in Cartland in this video very talk about that Theodoric functions
in case of Cartland.
So this function uses recursion in more optimized way than any other language such as Java or C programming
and so on.
Now what does the meaning of recursion.
Recursion means calling its own function from within the function.
That is the real call of function from inside its own function.
Now in case of Arlan whenever we call the same function multiple number of times such as hundreds of
thousands of time then that recursive process is actually optimized and the Cartland simply prevents
the stack overflow exception because calling the same function recursively can simply blow up the stack
memory.
So in that case the Cartland simply optimize the code call the function recursively write and not try
to find a direct function.
We have to use the keyword of the wreck.
Now inside the intelligent ID I would simply write my code to find the one that uses.
Now what do you mean by the Fibonacci series is that suppose I have the number 0 and the next number
is then.
So the next number will be the sum of 1 and 0 that is when again.
And the next number will be one place of an equal to.
And then we will have two plus one such as three similarly triplets two such as five and next will be
five blistery eight.
And then it plays 5:13 and so on like this let's see 21 right.
And the series goes on.
So let us write a program to find a key cities so far that leads do find function.
So here I have simply defined a method of good food when I can number at the end its position.
Right.
And here I am busting to prime readers of in be that determines the starting point of the Fibonacci
in cities such as zero.
And when these two values we have to give so that we can get that third number right by adding these
two numbers.
And now this simply returns the value or the food when I can.
But at the end its position.
Suppose I-PASS six.
So the sixth number is actually eight.
So this function will simply return it.
Right.
Now here I am using the big integer.
No the purpose of using the big Indeed it is that this big integer class can hold a very large number
or in bigger value.
So you can call this big endangered as the big boss of the entire class.
Right and now here I am simply writing so as condition.
So if part is totally understandable but here in the is part you can see I'm simply calling Guert Fibonacci
number which is actually its own method here.
Right.
So if there is Fargus exec you did it simply execute this method again recursively.
So the recursion goes on like this in finite number of times.
Suppose if this is 10000.
So it will simply loop through 10000 times like this.
Right.
And now here let us solve this error by simply placing it less.
And so simply import the biggest danger right.
And now from inside the main method I would simply call this method so as to get the key number.
So here this is my main method insert which I'm simply calling print Ellen get when I number and simply
passing 5 as a barometer.
And the starting position as 1 and 0.
Right.
If I add in the call right now I will get Let's see some value among these numbers represent at the
fifth position.
So let us note in the chord and here we get five as output.
So their distress their defense their distress 7.
And let's see what happens.
And here we get 13.
So at the seventh position we have 13 right.
So the seventh number is we're getting 13.
If we type here 8 then we will get Let's see 21 like that.
So the series goes on like this.
So as many times so work with any value that we will give here the far will be executed and the recursion
will go on.
That is that is it will simply call its own method again and again it finds that is correct.
That is till this point gets executed right.
Now suppose if I type your hundred Let's see what happens.
So here we get a very big number value.
That is a number.
When I can them what are the 100 position.
Is this one.
Now if I type penthouse and let's see what happens.
So here our program has crashed just because we have just ran out of the stack memory.
So the Java Virtual Machine has simply printed out the stack overflow error.
That is it has simply thrown out this error of stack overflow.
So we are now out of stack memory.
So this is a usual scenario in all the programming language.
If you write the same code in case of Java Sea or C++ it was simply going to throw this error.
Right but in Codlin that things are different.
You can simply use that Theodoric keyword.
So this function now becomes dactyl recursive.
Right.
And now here.
Let us first try with hand-write number.
So I guess our code will execute normally.
So here we get the output right.
But this time using their Teletech function if they use 10000 as any value then let's see what happens.
So in the output we have very few which number what I need and this number goes on till the end.
You cannot find the end right here because the number is too large.
So in Scotland we have our deal direct function direct simply exit cutes the recursion internally.
That is without affecting the stack memory.
So without affecting the stack memory it's simply exit.
This method recursively about 10000 number of times without affecting your application in the runtime
by saving memory.
Right.
So the Gondolin provides an alternative solution for the stack overflow error.
So this was all about the real function in case of Cartland.
So now I guess slowly and steadily you will fall in love with Codlin because Cartland is very very powerful
version of Java.
Or you can see it is a future of Android.
So thanks for watching and have a good day.