Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Okay, so if he is serious, we know how to how to work with it and how how these serious look like.
And just a quick reminder, we know that the first element F zero equals two, what, two zero and that
F one equals two one and then F two equals two one also.
Right.
The sum of the two previous values and the same goes for F three equals two, F two plus F one.
And this we can specify if one is A and F zero, which is a total of one, and they say is a total of
two and so on and so forth.
And we know that the formula for F there are the anth variable.
The arts are index in the Fibonacci serious.
We'll be equal to half of and minus one plus F, R and of minus two.
Okay.
So that's basically the mathematical explanation behind the serious.
And we want to write a function, a recursive function that will be able to receive this and this index
in these serious r n return of a value add this index.
So one of the ways to do so is to use, first of all, recursion.
OK.
We could solve it using iterations, but we will solve it using the recursions.
And the first thing that we are going to do is to create a function which will be of type end because
we are working with integers here and we will call this function a feedback on Nadji feeB on muchI,
if I'm not mistaken.
And here we are going to specify the index itself that these function will get.
So and specifies that the index and we are looking for the value in this particular index.
So how should we do it?
We know that if we take a look at these are formulated, we had an explanation of the challenge.
We can see that we have here, too.
There are two base cases and the first base cases.
If F if An equals to zero, then the value of this position also will be zero.
So the first condition will look like this.
If if an equals two zero two zero, then return zero.
That's it.
And also another base base case and stubborn condition will be if and if an equals two one, then return
one.
Right.
Because we can see that no mathematical operation is required here.
And from and you know, when N is greater than one, meaning it's two or higher.
Then we should use some formula to find out what will be its result.
And this recursive function, recursive call.
We know that these function, these people not she knows to find the value for these given index and
so feeble, feeble, she knows to find the value at a given index N.
And we know that by by looking at this formula.
This recursive formula, we can say that this function will return.
OK.
So feeble.
Not you for n feeble energy for n will return the feeble energy feeble energy for N minus one plus three
one.
Archie feeble.
Not cheap.
Four and minus two.
Is that clear so far.
We simply take the rules off from the mathematical explanation that we had in the challenge introduction.
We know that f f the Fibonacci value at Index M equals to the Fibonacci value at index N minus one plus
the Fibonacci value.
Add in an index and minus two.
And that's pretty much all that we've written here.
So Fibonacci for an Fibonacci Faran equals two.
Fibonacci four.
And minus one last.
Fibonacci of and minus two.
That's it.
And each of these recursive calls is going to call these function for N minus one and in minus two.
And it's going to be kind of a tree that will return value on every branch until it reaches out some
stopping condition where and equals to zero or M equals to one.
So I hope that's clear.
We are not going to write some main function in this video because it's pretty simple.
Just create some variable and call these function for whatever index you want and bring the result in.
Just open up Wikipedia or Google to compare and see that your printed result is as expected.
So I'll see you in the next challenge.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.