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
All right, so that's another example in our Recursions section.
And in this video, what we are going to do is to write a function that received some natural number
NUM and returns there, factorial of this number.
And for those of you who is not so familiar with what factorial is, let's explain it in simple terms.
So a factorial by its definition is just a mathematical operation and is defined to be as the multiplication
of all natural numbers from one up to a given number.
So very similar to how we used to find the sum of all the numbers from one up to number.
The factorial simply finds the multiplication of all the numbers of all the natural numbers from one
to a given number.
So, for example, if we want to calculate the factorial for numskulls two three, then our recursive
function should return the result of one multiplied by two, multiplied by three, which is a total
of six.
And if we want to calculate the factorial for nummy equals two five, then our recursive function should
return the result of one multiplied by two and so on, up to five, which is a total of one hundred
and twenty.
So basically we can say that the function for a given NUM should return the following result of one
multiplied by two, multiplied by three and so on.
Up until a given num so num minus one will be our one element before the last one.
And num will be our last element in this multiplication factorial formula.
Not so complicated.
Right.
And it's basically it's pretty similar to the previous example.
We can see that the only thing that changed between these example to the previous one is that we just
instead of using the addition operator, we are just using their multiplication.
So also very similar to the previous question.
So you will be able to write the factorial function with ease.
I suggest using the same approach as we did previously and just to show you the multiplication from
left to right.
So instead of taking a look at this formula from the left to the right.
Right from one multiplied by two and so on, we will look at from right to left, which is num multiplied
by num minus one and so on and so forth.
You've got the idea the result will be the same.
Would it change anything, just the order that would look at the multiplication.
But the overall result is going to be the same.
And now it's time for some Hanzo in our programming language.
So let's go.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.