All language subtitles for 15. Pell Number in a Pell Sequence

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

Welcome back, ladies and gentlemen, and in this video, we are going to talk about what do you want

to talk about in this video, guys?

Let me know.

So what I'm going to talk about is basically about, hell, no.

Hell no.

So for those of you who is not familiar with what our poll numbers are, basically that's just the sequence

of integers also known since ancient times.

And what we are going to do is simply not dive into all of the theory and everything behind these poll

numbers and all of its all of its rules and so on and so forth.

But rather, what I'm going to show you is, is just similar to the Lucas' exercise into the Fibonacci

exercise that we've made.

I'm going to show you a simple kind of formula, a simple set of rules that will be that will give you

the option to find any element in the pail sequence, basically to find the Pell number in a sequence

of PILT numbers.

OK, so with that with that being said, let's get started right from the formula.

And the bell sequence is defined by the following rules, so let's say we have Pål sequence.

OK, and if you want to find OK, if you want to find me, just draw it nicely.

OK, so pale sequence.

And if you want to find any element.

OK, so that's the bell sequence.

One, two, three, four.

OK.

And so on and so forth.

OK, these are the elements in this sequence and basically the first element is defined as index zero

and index and equals to zero and equals to one and so on, so on and so forth.

OK, so these are the indexes.

And these are the values.

OK, so indexes are defined as end and values will be defined as b.M.

OK.

Awesome.

So but basically you have this question like, how should you know how to find this value?

M. And for that, as we said previously, there is a strict set of rules to how you can calculate the

Pell number at index.

And so B.M. equals to zero if and equals to zero one if and equals to one and two multiplied by P and

minus one plus and minus two for any M which is greater than one.

OK, so these are basically the strict rules to calculate and find any Pell number in a pail sequence

double.

OK, so two multiplied by the previous value plus the pre previous value.

OK.

Awesome, so let's just try to see how the sequence will look like, so at any goals to zero, the value

will be zero.

At any goals to one, the value will be one and two equals to two.

The value will be two multiplied by the previous value, which is one.

That means two plus zero, which is to the next value for an equal to three.

OK, we can say that for an equal to three, we will say that B three equals to two times P two plus

P one.

And we know that P two equals two two.

So two multiplied by two is four plus one equals two five.

OK, so that's basically how you calculate the P&L number in a P&L sequence.

You know, once this mathematical explanation, mathematical formula is clear, do you guys we are ready

to start writing down our code.

OK, and what we are going to do in this exercise is basically we will use we will create two functions

just, you know, like to practice your knowledge and your experience in giving you some more Hands-On

exercises.

We are going to write two functions on.

The first function will be a recursive function that will get some natural no end, OK, which represents

the index.

And these function should recursively calculate and return the P&L number at Index M.

OK, basically, just like you use these formula and also assigned to the recursion or recursive function,

we are going also to create a non recursive function that will basically do the same logic, the same

algorithm to find the value of Pell number at Index M.

OK, so there is pretty pretty much on this exercise is kind of similar to Lucas in Fibonacci, but

still that's a good practice that good hands on a good time when you can compare your knowledge and

make sure that you understood the previous exercises as well as these current one.

So get yourself ready and let's start.

All right.

And first of all, what I'm going to do is basically just to, you know, a little bit clear the screen.

OK, so let's clear the screen a little bit right here so that it won't bother us while we are going

to write down our amazing code.

OK, so if you wanted, you could just R.

Yeah, that's OK.

So OK, so let us start so let me grab this one.

OK, so what we are going to do is to write a function for that.

And what do you think, guys?

What should be the type of this function?

Should it be an integer, a double float, maybe character or maybe even should be a void.

So what do you think?

And of course, the answer is very simple.

It's going to be integer since we know that we have here we deal with integers.

So and we are going to say, hell no.

OK, so let's see recursive and this function as request that is going to get an integer and which represents

the index.

OK, and now once we've got it, let's try to think of how we can write down the body of this function.

And since we are talking about a recursive approach, then basically what we will do is, first of all,

treat these two base cases and just solve them.

So if and equals to zero, then in this case, what we would like to do is return zero.

Right.

Let me just make it here.

Clear.

OK, so if an equal to zero, return zero and if an equal to one.

And in this case, what we would like to do is to return one.

Otherwise, what we would like to do.

OK, so basically we've dealt with these two base cases.

Now what we would like to do is simply to make the recursive call.

And once again, that's very similar to our previous exercises when we talked about Lucas' serious and

Fibonacci's serious and whatever serious we talked about.

So the recursive call is very similar.

We simply follow this kind of structure of these kind of rules.

So return.

And what would what would we like to return to multiplied by the previous number?

So that's the pill number, recursive four and minus one, plus pill no, recursive four and minus two.

So that's basically the recursive call.

So once again, guys, what what can we see now on the screen, basically we created a function that

is called PILT, no recursive.

And you have to understand that when you when you using a recursions, one main thing that is happening

behind the scenes is that you simply define a function that is capable of doing some task.

OK, and what is this function is capable of doing?

This function is capable of finding out the Pell number for a given index.

And this index may be whatever natural, of course, which is greater or equal to zero or greater or

equal to zero.

And so these function, its main task and its main objective and its main functionalities to find the

PIN number at index and how it does it, it doesn't matter.

OK, so we know that if you want to find the pool number four, index three, then it's definitely going

to be two multiplied by the pool number four index to plus index, bill number four, index one.

So basically you are going to call this function over and over again.

And you know that there is a function that knows to find a phone number for current index.

So this index can be in minus one and it may be also in minus two.

So these current function four, and it knows that it can use another function, which is the same function

for another index, and it will take care of these computations.

So hopefully these explanation and kind of additional demonstration is clear to you is how to maybe

look at this recursion concept.

And with that being said, let us proceed to the non recursive solution, just if you like to summarize

the topic of Pells sequences.

So regarding the non recursive, what do you think should be done by the video in return once you have

a solution?

And we are going to do that together.

All right, so now once you're back, basically I'm going to copy these signature of the function because

it's going to be pretty much the same, just the name is going to be changed.

So let's just add pail.

No, not recursive.

OK, so getting in and, you know, basically it's going to be once again, similar to one of our previous

exercises.

We are going to say are let's start with the two biggest cases.

So let's just copy it, because it's pretty much the same thing, right?

If if if so, if an equal to zero return zero equals to one return one, you know, what we will start

is the next index that is not on the list of our base cases.

And what I'm going to do is to do like four I equals to are we didn't create dice or let's create I

said and I and let's create also and I don't know in previous and current.

OK, maybe we can also initialize them.

OK, so the previous will be equal to zero and the current will equal to one because the previous I

read here, the other end equals zero in the current four and equals to one.

So that's why the R values are zero and one zero and one.

And I'm going to start the for loop for I equals to two since I know I can use both the previous and

current to calculate the next value.

OK, because we know that this will be the current, this will be the previous and both of them will

be used to calculate the next one.

OK, so four equals to two that the initialization phase I as long as I is less than or equal to an

I plus plus.

OK, very simple for a loop.

We are going to use iterations here.

OK, and now what we'll also create is basically additional variable that's created.

I don't know.

Um hmm.

What should we call it.

Let's call this variable just for simplicity.

Let's call it the.

OK, so they stay or maybe next year.

Next.

Let's call it next.

OK, so let's call it next.

So this next is going to be equal to what do these calculations over the next value equals to two times

multiplied by the current occurrence so far.

Is this M minus one plus.

Plus what.

Plus the previous value.

OK.

And also, what we are going to do is to say now that previous, which was P and minus one, should

now be the PM PM right.

One second.

And the previous the previous, which was P and minus two, should be now P and minus one.

So previous equals to current.

OK, and finally also we have to move the current also one further using the index.

So the current will be equal to what do the next OK to the next in this iteration because the next on

the next iteration is going to use the previous next to calculate it.

Right.

So that's basically it for this solution.

Of course.

Return finally, once you're done, return the correct current or next whatever comes to your mind,

because both of them will have the same solutions, the same value.

So return next in this case.

And one thing to mention, guys, if you still have any questions, of course, feel free to ask them.

Of course, regarding these non recursive approach, maybe, maybe, maybe, maybe another naming conventions

maybe used for the previous and the current.

They maybe maybe they are a little bit confusing.

So you may always use like, I don't know, let's call it on.

Let's call it previous.

OK, you can call it as you can call it is previous and this will be like pre previous.

OK, so previous will be minus one and pre previous will be and minus two, so are previous and next

will be current.

OK, I'm just giving you the same solution just with, with a dish, basically different variables,

names.

OK, so maybe it will be a little bit easier to use so that the current value is calculated by multiplying

two times the previous plus one time the pre previous, which is this one.

OK, and then you say like previous are three previous will be equal to previous.

OK, this means that the value of P and minus two, um that the value of P and minus two will be equal

to P and minus one.

In this case these duration and the current will be equal to the current.

What you should be will do should be equal to previous.

OK, so three previous should be equal to current.

OK, so guys basically basically I just changed the naming.

I hope I did everything right here because we needed kind of quickly just to demonstrate.

But I think you got the concept of how Paille sequences work, what they are, when they should be used

and so on.

And if you still have any questions, feel free to ask them.

And of course, I will see you in the next videos.

So until then, have a great time.

My name is Vlad Alphatech.

See you then.

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