All language subtitles for 18. Sum of Odd Numbers Sequence - 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
hu Hungarian Download
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, so what we have to do in this exercise is simply to write a program that receives some and

some value and from the user so receives and from the user and based on these and we are going to receive

OK to receive or receive or read and values or better say, integers.

And we are going to sum all the odd numbers and to return and to basically print these some sum, all

the old numbers.

OK, so how we are going to do that, let's start with just creating the variable and reading this value

once again from the user and storing it inside of an variable.

So an answer and which is also the number of values, a number of values in a sequence of numbers that

we are going to insert.

Right.

So enter and some.

And now let's read this value from the user and story inside the variable and so storing inside variable

in.

And now what we are going to do is just to use some loop.

Right.

And this is going to be very, very simple.

Let's say we have here I sell for I equals to you.

To what?

To what should be I equal to R equals, let's say to one, as long as I use less than or equal to N.

Okay I plus plus.

So one way to do that is to use the for loop.

Another way to do that is to use the wire loop as long as it is greater than one or zero, whatever

you choose using the greater than or equal.

OK, so let's go with the four.

No problems with four equals to one as long as I is less than or equal to and basically are making the

easy duration in times.

OK, so now let's just read the value from the user.

Let's say we will have also additional variable called current value and we will simply read the value

from the users or print f cancer of value and zero value.

Now read this value from the user so it inside current value.

And now we have to ask a simple question.

If current value divided by two modulo two equals to one, which means it's it's an odd number, then

in this case we should basically some this solution, these value.

So let's say also all the sum will be equal to zero.

So on some will be equal to zero.

There you go on some loss equals two to watch to the current value.

OK, so that's how you sum up all the old values in this sequence.

And finally, you're going to print.

OK, so all that sum equals to percentage.

And there you go.

And yeah, I think that we covered up everything as we should, so let's build and run it to see that

everything works correctly so and will represent the size of the sequence.

So, for example, five, let's go like one, two, three, four and five.

So we have some problem.

So what's the problem?

Osam equals to some odd, very odd number.

Very strange.

So we can see here that we didn't specify is instead of the placeholder here instead of the percentage,

what will be the values of the value should be or something.

So let's hopefully build and run it once again and see that everything works correctly.

So one, two, three, four and five.

So all some equals to nine.

And let's make sure that five plus three, which is eight plus one, which is nine awesome.

And similar approach can also be done for finding also the even values and also finding the the odd

sum and the even some basically we can also find both of them in a sequence.

So these are kind of questions that a lot of teachers like to ask students.

But now you know how you can tackle this problem even without using arrays, which we haven't covered

up yet, but we will talk about them.

So you simply get some value from the user and they and specify the size of the sequence that you are

going to use.

Then you readjust these values one by one, asking some conditions.

And since you don't care to store these values for later, use it.

That's why probably this approach is one of the best.

So thank you guys for watching.

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.