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
So another day, another challenge, right, guys, in this challenge, we proceed with practicing functions.
And the reason for that, for why I so much insist on practicing more and more exercises with functions,
is because this topic is actually so important.
And it will guide you during most of your programming career.
So pay close attention and let's go.
And what I want you to do in this challenge is simply to write a function that will receive a number
of an integer type.
And then the function is going to calculate its factorial.
And just a quick reminder, for those of you who is not familiar with water, if Victoria really means
and how it's calculated, the factorial of a given number is calculated by multiplying all the natural
numbers from one up to the given number.
So a factorial of NUM equals two one multiplied by two by three and so on up to the multiplication by
NUM.
All right.
In this case, we specified D as M name equals to M.
So for example, if you have a m to calculate the factorial of three equals two, one multiplied by
two multiplied by three, which is a total of just six.
And if you have to calculate the factorial of a number five, then you will say that eight equals two,
one by two by three by four by five, which is a total of one hundred and twenty.
Whoops.
Here I have only six.
That should be fixed to one hundred and twenty.
So basically you've got the point hand and that's my mistake.
I will fix it up.
So basically you multiply all the numbers from one, two, three up to the specified number to find
Edes factorial.
And then the function is going to return.
The result?
It will calculate the factorial and return the result.
And not printed to the screen, but rather it will return it.
So there we can check with the main function that it actually works as we expected it to work.
And that will basically bid for these function.
And one thing that I would like you to notice is that if then if a given number is going to be a negative
number, then the function will return minus one, because we cannot calculate a factorial for a negative
number.
And these minus one will specify that something something was wrong there.
And we will know how to treat it later on.
So good luck, guys.
Give it a try and I'll see you in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.