All language subtitles for 9. Sequence of 9s

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

All right, what is going on and in this video, we are going to solve additional new exercise regarding

functions and basically to make some mathematical operations and so on.

And what I want us to do is simply to write a function that receives some number, let's say function,

receives some number, and this number will be called it in a length.

All right.

And what the function should do is to make some mathematical operations, some mathematical magic that

right after these magic or the body of the function has been executed, the function is going how to

calculate and to return the number.

OK, the number, the following number.

So nine nine nine until nine, right off the given length.

So I think an example is much clearer.

So if length is, let's make point to examples.

So if length length is going to be like three, then the return value should be nine nine nine.

OK.

And if the length was like length equals to five, then the result is going to be like five times nine

to ninety nine thousand nine hundred ninety nine.

OK.

So I hope the instructions are clear and let's dive into coding.

OK, but first of all, think about the solution and do things that you have to bear in mind is basically

I want you to think of them by yourself right now.

These are, first of all, what is the process of working?

How will you work?

It's not like you have just to print the values, right.

You have to return to return.

OK, if it was like only to print this number to the screen, then there will be no problems at all.

Right.

You simply would go like using some lube and you would like just print all the values.

You would just print nine is just length times.

OK, so it will be like a simple for loop from a equals to one as long as as less or equal length simply

print F nine and so on until you're done.

But that's not something that we want.

We want to calculate this number, maybe to hold it also in some variable and finally to return it.

OK, so the function is going to return.

So let's start writing the structure of the function and basically think about is is there any limitation

that you would like to like to care to take care of?

Maybe some type, because that may also be a problem for the signature of the function.

But we are going to discuss about it at the end of this video.

First of all, let's just write down the most trivial way, the most trivial signature.

So the signature will look like this.

So it's OK because we are going to return probably an integer.

That's something we are going to discuss, as we just said, and let's call it nine number, OK, nine

number of these function will create and a number based on the length of the sequence is going to receive.

Awesome.

So that's the signature of the function.

And basically, how should you treat and how we should you solve this question?

First of all, we need to understand that we need to create some new number.

So let's assume that we will make some I don't know, ain't nothing, OK?

And this thing now will be used for our calculation.

And what we are going to do is simply to understand that at every phase, OK, off some loop that we

are going to use in the help of this, ain't I?

So we will use some loop and we'll start this loop from I equals to, let's say I don't know, zero

up until I use less than length.

OK, I plus plus and what we are going to do in the body of the loop is basically every time.

OK, so let's just set now to be zero at the beginning.

What we would like to do is the following so now equals to zero.

And in the first iteration we would like num to be equals to, to be equal to what should be equal to

do nine.

OK, the second iteration number should be equal to 999.

Right.

That's what we want to achieve.

But how these 999 can be achieved, it can be achieved as the following.

OK, it can be achieved by multiplying the previous NUM by ten.

So it will be like now multiplied by ten plus nine.

OK, so it will be a total of ninety nine.

And then in the next iteration, we are going to use pretty much the same number multiplied by 10,

just that now now equals to ninety nine, the previous value of none plus nine.

So this will give us nine hundred and ninety plus nine, which is nine nine nine three times.

OK, so that's the first iteration, the second, the third and so on.

Up until up until what.

Up until you get you finish this length.

All right guys.

Is that clear so far.

Awesome.

So what we have to do right now is simply to utilize the body of these for a loop.

And what do you think what do you think should be the body here?

Take a moment.

Think about it.

Right.

Because we've written all the structure, all the values, all the information is already right in front

of you.

So look at this.

Try to come up with some solution, with some idea.

OK, try try try to make something out of this.

And what we are going to do now is basically to construct some formula and this formula says the following.

So at every duration we will take to calculate.

Now we will take the previous now the previous value of now multiplied by 10 and add a nine to it,

which is also will work because on the first the duration when we say now equals to nine.

That's not entirely related to the formula, but rather we can also represent it is now multiplied by

ten plus nine.

Right.

And we know that the previous number, the number we set up here to be zero zero zero multiplied by

ten is zero plus nine is nine.

OK, so that's the result from here.

And then we go to the next iteration.

So to calculate the next next then we calculate now we will take the previous number, which is nine

multiplied by ten, which is 90 plus nine, which is ninety nine and so on and so forth.

Up until you do this operation length time and you will receive this number, this sequence of nine

nine nine length times.

All right.

So to put it simple, in our code, we will say that number equals to the previous Naameh.

Multiplied by what?

Multiplied by ten plus nine.

All right.

So that's basically all there is to it just to calculate this value.

OK, so now once we know that this the this solution is pretty much legit, let's also return this sequence.

There's no return on this now.

Sequence a sequence of nines.

OK, so nine.

No.

Awesome.

And now let's also go down in here.

I don't know, prenda a nice message.

Let's just what we want to do now is to test the these nine number of function works as expected.

So for them to have either please enter or length for the ninth sequence sequence.

Right.

We are going to read this value from the user and store it inside some variable it's created and length

sequence.

OK, and then we will read really second half percentage, the entire length sequence.

And now what we are going to do is just basically to call these functions.

So also let's create some identity and result and we will do like a result equals two nine number nine,

number four length sequence.

All right.

And these results should also should basically hold the nine nine, nine length times.

So that's primitive.

The result equals to percentage the resolution and here will specify result.

Great.

So now what we have to do is just to run these programs.

So let's build and run it and make sure everything works as expected.

So let me give it here.

So hi there.

Please enter blank for the night and sequence.

It was it was supposed to be 9th, so let's make it five and there we go.

Result equals two nine nine nine five times.

Awesome.

Let's make sure that it works also.

OK, so let's hear it.

Another three also works fine.

Great.

Seems to be working correctly.

But now just before you're about to celebrate that everything works as expected, I want to take care

of two things.

The first thing that we need to take care of is just the ending condition.

And we need to like to understand that this problem will not go that smooth if length will be like a

negative number.

OK, so maybe a good idea would be to add here also some message and to say if length is less than or

equal to zero, then in this case bring some descriptive message to the user.

And another thing that we need to take care of, which is also very important, is the fact that let's

try to build and run it and see what happens.

So let's go like this.

So we said that if we enter here five, we will get nine nine nine nine nine.

And if we will do it like four seven, it will be seven times nine.

But what will happen if we enter here?

Thirty one, do you think will be printed to the screen.

So let's run it and see what happens.

OK, so that's very, very strange, very strange.

So let's build it around it once again and see what happens if we enter even, I don't know, 15.

Negative number.

What's going on here, guys, what's going on?

Let's also add, I don't know, 10.

Very strange, why, why, why is that what's happening?

So let's see also for eight, but for eight, which looks OK, so what's the problem?

Where, where, where?

It basically starts to like to do not work correctly and to give us some arbitrary numbers.

What do you think?

And that's that's quite a problem.

So what I suggest you to do is basically to understand the concept of using integers.

And we know that the jurors are basically just data types that are used to hold different values of

an integer type in our C programming language.

But the problem is that these variables, they are also kind of limited in terms of what values they

can store, because we remember that a typical integer is just four bytes of memory.

Right?

It's just four bytes of memory.

And since we know it, it's kind of four bytes.

We know that there is some limitation on the value that it can that it can store.

OK, so there are there is some range of values that an ancient integer number can store.

And this value lies between, if I'm not mistaken, from about minus two million up to two million or

three billion.

What was it?

I think billion from from like nine to nine to ten digits numbers.

OK, so that's basically the range that on an integer variable can store.

And if you're going like to specify to specify 30, 30 digits that you want to print.

Right.

These nine nine nine nine that you want to do like this nine nine nine nine nine that you want to get

like 30, for example, digits in a number, then our variable will not be able to do this task and

some information will not be displayed correctly.

So if you would like to handle it even better, there are, of course, better variable data types,

for example, like first of all, using longer, OK, longer is a data type for storing eight bytes

of values.

It will be a better choice here.

So simply, you will need change like this into longer than just the printing also.

And basically you will be able to store I don't know.

I don't remember exactly how much, but I think it's about 20, 20 digits, something like that.

But I don't remember exactly.

You also may check it out, of course, in the documentation.

And another way, that's not something I think we will cover up in these course is to use some conversion

mechanism.

That's a question that he's being asked the lot in.

At least I remember he has been asked a lot in interviews, questions and needs regarding how you can

represent a given number.

OK, with kind of no no limitations.

All right.

So the process will be like to there will be there will be, of course, limitations, but there will

be like really, really major, because you should take a value of an integer, some number and basically

to convert it to and from a string.

And then, you know, the string can have multiple characters, much more than just one variable of

an integer, a double or a float can hold.

And basically that's how you're going to work.

But that's a totally different function, a total different functionality.

That's not for this video.

But that's very important for me to give to you as a bonus and as an understanding for the whole process.

Oh, so I think this video was not an easy one, it was a good one with a lot of very valuable information.

So as always, guys, thank you so much for watching.

Let me know in the comments.

Give me some review that I will know that my videos are helping or helping you.

And yeah, this is it.

Thank you.

My name is Vlad Alphatech.

Goodbye.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.