All language subtitles for 6. Challenge 3 - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So let's start with the solutions right away.

First of all, what I want you to do is to specify the function type, and we know that a multiplication

of the jurors will be equal to integers.

So the function is going to return an integer type.

So we just specify end.

And now we specify the function name in these cases.

Factorial four.

Sorry about that factorial.

And we know that a functional receives a number.

So int num.

Now we are going to specify the functions body and in the functions body.

We are going to first of all, to make sure that the number is not negative.

So if it is less, if NARM is less than zero.

And in this case the function is going to return minus one.

Right.

That what we agreed on, that the function is going to return minus one if the number is less than zero

and we can not calculate the factorial for it.

So otherwise otherwise if that's not happening.

Right.

We do not need to.

We are not required to use the yellow section here.

We can just proceed with our code.

Because if this line if this condition happened to be true, then we will simply return the result and

we will not continue running the next lines of code.

So there is no need for the yellow section here.

Now, what we are going to do is to probably use some loop, right?

We are going to use some loop.

And I want us to use a loop.

Let's use a for loop.

So in it, I will create an IV variable and then we are going to specify the slope.

So for I equals two one as long as I is less or equal to none.

Right.

Because we are going to multiply by I want every duration and I plus plus.

And now what we are going to do is to multiply on each iteration, the number we have so far multiplied

by I.

So it will be one multiplied by two.

By three.

Until we reach these numbers.

So for that what we also need, we need to create a in some some variable that will store the result.

And let's call this variable been resolved.

Okay.

So the result will hold the result.

The result of the factorial factorial.

And now will also.

What what should we do.

Well, so we should specify some.

We will we should initialize that these variable to be let's say one.

Okay.

This variable will be one end of every duration.

We are going to multiply it by I.

So result equals to the previous result multiplied by I.

So on the first iteration we will have resolved.

Equals to previous result which is one multiplied by one.

All right.

This operation may be actually unnecessary.

In this case.

But we'll leave it this way.

So result equals the result multiplied by I.

And on the next iteration it will be equal to one.

Multiplied by two.

Right.

Because I is going to be equal to two.

We incremented it here.

And on the 30th duration, we will have previous result, which is two multiplied by three.

And so on and so forth.

And that's how you calculate the result in C programming language.

And once you've calculated the result of the factorial of these number, you are going to return it.

Right.

So return result.

And that's it.

That's how you calculate the factorial for a given number.

Right.

So mathematical operation.

We have written a function that will do this for us.

Now, all that remains is simply to go to the main section and use some variable.

It save my number.

My num print a corresponding message.

Enter the user.

Right.

Please, please insert insert a number that you want to calculate the factorial.

So please enter the numbers.

Can I have percentage the.

You put it inside my now mine number and then you're are going to call these function and you are going

to say all right.

So are the factorial.

All right.

Let's say collectively as factorial.

Here we will specify percentage the of the number itself.

So percentage D equals two equals two percentage.

And instead of the first percentage, B, right.

Instead of this place holder, we are going to specify the number itself that we received from the user.

And here, instead of these percentage D, we need to specify the result of the factorial on these given

number.

And the result is going to be the function we are calling the function with.

No, and the function is going to return, the function is going to return.

So instead of this function, here will be some return value, which is the result.

We've calculated by multiplying this number of times.

So I hope that's clear.

We could we could use another variable in store.

The result of the factorial inside of this variable.

But for these exercises, that will be simply useless.

So let's build and run it and see that both of our examples for these exercise works are so pleasing.

Certain, no.

Let's say three.

So the factorial for three is six.

And let's try the second number.

It was five four.

Make a mistaken.

So the factorial for five is one hundred and twenty.

So you've developed such a nice mathematical operation that you can also add to your calculator that

you're developing.

So thank you both for watching 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.