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
What is going on, guys, and welcome to our first example that we are doing and these recursions section
of this video, in this example, we are going to write a function, a recursive function that will
receive some naturale number, which is numb, and then it will return the sum of the arithmetical progression
from one up to number.
So we are going to write a recursive function that will call itself and once it calls itself, it will
divide.
The main problem into some sub smaller sub problems until it reaches some stopping condition.
And the result will be to find the sum from one up to number.
So, for example, if we received anomic Wil's two three, then our recursive function should return
the sum of one plus two plus three, which is a total of six.
And if we received Nomic was two five, then our recursive function should return the sum of one plus
still plus three plus four plus five, which is a total of fifteen.
So as we can see, the sum of all the numbers from one up to number five for all their natural numbers
from one to NUM.
So that's what we want to do in this exercise, in this example.
And we know that it can be done easily just by using some for a loop or while loop.
Right.
But we are going to use our new concept, our recursion concept, to solve this exercise and to make
things a little bit easier for us.
I suggest to write or some is the following way.
One plus two plus three on so on up until you sum num minus one and the num itself to your general sum.
Okay.
And instead of looking at these sum in this way, it's just a hint that you may also look at the sum
in the following way, which is pretty much the same.
Right.
It doesn't matter if you some from left to right or from right to left.
The sum is going to be the same.
But that's the first hint that I give you to solve this example and take a few moments to think about
how you would do it.
And we are going to solve it together.
So let's go.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.