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
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
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
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
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-PT Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,330 --> 00:00:06,900 Welcome back, ladies and gentlemen, and in this video, we are going to talk about what do you want 2 00:00:06,900 --> 00:00:08,940 to talk about in this video, guys? 3 00:00:09,480 --> 00:00:10,590 Let me know. 4 00:00:11,340 --> 00:00:18,240 So what I'm going to talk about is basically about, hell, no. 5 00:00:19,320 --> 00:00:20,100 Hell no. 6 00:00:20,790 --> 00:00:29,490 So for those of you who is not familiar with what our poll numbers are, basically that's just the sequence 7 00:00:29,490 --> 00:00:32,910 of integers also known since ancient times. 8 00:00:33,480 --> 00:00:42,350 And what we are going to do is simply not dive into all of the theory and everything behind these poll 9 00:00:42,360 --> 00:00:47,700 numbers and all of its all of its rules and so on and so forth. 10 00:00:48,000 --> 00:00:55,380 But rather, what I'm going to show you is, is just similar to the Lucas' exercise into the Fibonacci 11 00:00:55,380 --> 00:00:56,530 exercise that we've made. 12 00:00:56,820 --> 00:01:08,130 I'm going to show you a simple kind of formula, a simple set of rules that will be that will give you 13 00:01:08,130 --> 00:01:17,730 the option to find any element in the pail sequence, basically to find the Pell number in a sequence 14 00:01:17,730 --> 00:01:19,560 of PILT numbers. 15 00:01:19,590 --> 00:01:25,500 OK, so with that with that being said, let's get started right from the formula. 16 00:01:26,310 --> 00:01:35,230 And the bell sequence is defined by the following rules, so let's say we have Pål sequence. 17 00:01:36,000 --> 00:01:42,720 OK, and if you want to find OK, if you want to find me, just draw it nicely. 18 00:01:42,850 --> 00:01:44,520 OK, so pale sequence. 19 00:01:44,920 --> 00:01:47,490 And if you want to find any element. 20 00:01:47,580 --> 00:01:49,620 OK, so that's the bell sequence. 21 00:01:49,620 --> 00:01:52,720 One, two, three, four. 22 00:01:52,740 --> 00:01:53,000 OK. 23 00:01:53,010 --> 00:01:54,240 And so on and so forth. 24 00:01:54,240 --> 00:02:03,030 OK, these are the elements in this sequence and basically the first element is defined as index zero 25 00:02:03,030 --> 00:02:07,790 and index and equals to zero and equals to one and so on, so on and so forth. 26 00:02:07,800 --> 00:02:10,410 OK, so these are the indexes. 27 00:02:11,510 --> 00:02:13,790 And these are the values. 28 00:02:13,830 --> 00:02:20,450 OK, so indexes are defined as end and values will be defined as b.M. 29 00:02:20,750 --> 00:02:21,160 OK. 30 00:02:22,050 --> 00:02:22,630 Awesome. 31 00:02:22,980 --> 00:02:30,210 So but basically you have this question like, how should you know how to find this value? 32 00:02:30,630 --> 00:02:39,000 M. And for that, as we said previously, there is a strict set of rules to how you can calculate the 33 00:02:39,000 --> 00:02:41,250 Pell number at index. 34 00:02:41,250 --> 00:02:55,110 And so B.M. equals to zero if and equals to zero one if and equals to one and two multiplied by P and 35 00:02:55,110 --> 00:03:02,910 minus one plus and minus two for any M which is greater than one. 36 00:03:03,030 --> 00:03:12,630 OK, so these are basically the strict rules to calculate and find any Pell number in a pail sequence 37 00:03:12,630 --> 00:03:13,200 double. 38 00:03:13,830 --> 00:03:22,630 OK, so two multiplied by the previous value plus the pre previous value. 39 00:03:22,650 --> 00:03:23,040 OK. 40 00:03:24,230 --> 00:03:32,480 Awesome, so let's just try to see how the sequence will look like, so at any goals to zero, the value 41 00:03:32,480 --> 00:03:33,410 will be zero. 42 00:03:33,530 --> 00:03:38,290 At any goals to one, the value will be one and two equals to two. 43 00:03:38,390 --> 00:03:43,940 The value will be two multiplied by the previous value, which is one. 44 00:03:44,120 --> 00:03:51,620 That means two plus zero, which is to the next value for an equal to three. 45 00:03:51,720 --> 00:04:00,560 OK, we can say that for an equal to three, we will say that B three equals to two times P two plus 46 00:04:00,800 --> 00:04:01,570 P one. 47 00:04:02,000 --> 00:04:05,230 And we know that P two equals two two. 48 00:04:05,270 --> 00:04:10,880 So two multiplied by two is four plus one equals two five. 49 00:04:11,210 --> 00:04:17,420 OK, so that's basically how you calculate the P&L number in a P&L sequence. 50 00:04:18,020 --> 00:04:26,360 You know, once this mathematical explanation, mathematical formula is clear, do you guys we are ready 51 00:04:26,360 --> 00:04:29,880 to start writing down our code. 52 00:04:29,900 --> 00:04:38,930 OK, and what we are going to do in this exercise is basically we will use we will create two functions 53 00:04:38,930 --> 00:04:46,130 just, you know, like to practice your knowledge and your experience in giving you some more Hands-On 54 00:04:46,130 --> 00:04:46,820 exercises. 55 00:04:46,820 --> 00:04:49,810 We are going to write two functions on. 56 00:04:49,820 --> 00:04:58,010 The first function will be a recursive function that will get some natural no end, OK, which represents 57 00:04:58,010 --> 00:04:58,940 the index. 58 00:04:59,480 --> 00:05:06,400 And these function should recursively calculate and return the P&L number at Index M. 59 00:05:06,410 --> 00:05:15,440 OK, basically, just like you use these formula and also assigned to the recursion or recursive function, 60 00:05:15,440 --> 00:05:23,420 we are going also to create a non recursive function that will basically do the same logic, the same 61 00:05:23,420 --> 00:05:29,910 algorithm to find the value of Pell number at Index M. 62 00:05:29,960 --> 00:05:38,330 OK, so there is pretty pretty much on this exercise is kind of similar to Lucas in Fibonacci, but 63 00:05:38,330 --> 00:05:44,090 still that's a good practice that good hands on a good time when you can compare your knowledge and 64 00:05:44,090 --> 00:05:49,760 make sure that you understood the previous exercises as well as these current one. 65 00:05:50,150 --> 00:05:52,460 So get yourself ready and let's start. 66 00:05:53,480 --> 00:05:53,960 All right. 67 00:05:53,960 --> 00:06:00,830 And first of all, what I'm going to do is basically just to, you know, a little bit clear the screen. 68 00:06:00,860 --> 00:06:07,640 OK, so let's clear the screen a little bit right here so that it won't bother us while we are going 69 00:06:07,640 --> 00:06:11,220 to write down our amazing code. 70 00:06:11,360 --> 00:06:15,540 OK, so if you wanted, you could just R. 71 00:06:16,490 --> 00:06:17,580 Yeah, that's OK. 72 00:06:17,690 --> 00:06:22,310 So OK, so let us start so let me grab this one. 73 00:06:22,460 --> 00:06:26,560 OK, so what we are going to do is to write a function for that. 74 00:06:26,990 --> 00:06:28,020 And what do you think, guys? 75 00:06:28,070 --> 00:06:30,230 What should be the type of this function? 76 00:06:30,240 --> 00:06:36,780 Should it be an integer, a double float, maybe character or maybe even should be a void. 77 00:06:37,430 --> 00:06:38,580 So what do you think? 78 00:06:39,890 --> 00:06:42,800 And of course, the answer is very simple. 79 00:06:42,830 --> 00:06:48,290 It's going to be integer since we know that we have here we deal with integers. 80 00:06:48,290 --> 00:06:53,420 So and we are going to say, hell no. 81 00:06:53,630 --> 00:07:03,650 OK, so let's see recursive and this function as request that is going to get an integer and which represents 82 00:07:03,650 --> 00:07:04,440 the index. 83 00:07:04,460 --> 00:07:12,920 OK, and now once we've got it, let's try to think of how we can write down the body of this function. 84 00:07:14,310 --> 00:07:20,250 And since we are talking about a recursive approach, then basically what we will do is, first of all, 85 00:07:20,250 --> 00:07:25,110 treat these two base cases and just solve them. 86 00:07:25,140 --> 00:07:31,630 So if and equals to zero, then in this case, what we would like to do is return zero. 87 00:07:31,830 --> 00:07:32,250 Right. 88 00:07:33,060 --> 00:07:34,980 Let me just make it here. 89 00:07:35,250 --> 00:07:35,880 Clear. 90 00:07:35,910 --> 00:07:43,560 OK, so if an equal to zero, return zero and if an equal to one. 91 00:07:43,720 --> 00:07:47,250 And in this case, what we would like to do is to return one. 92 00:07:48,630 --> 00:07:51,330 Otherwise, what we would like to do. 93 00:07:51,360 --> 00:07:55,770 OK, so basically we've dealt with these two base cases. 94 00:07:56,280 --> 00:08:00,660 Now what we would like to do is simply to make the recursive call. 95 00:08:01,410 --> 00:08:09,900 And once again, that's very similar to our previous exercises when we talked about Lucas' serious and 96 00:08:09,950 --> 00:08:14,410 Fibonacci's serious and whatever serious we talked about. 97 00:08:14,820 --> 00:08:17,420 So the recursive call is very similar. 98 00:08:17,430 --> 00:08:22,350 We simply follow this kind of structure of these kind of rules. 99 00:08:22,590 --> 00:08:23,830 So return. 100 00:08:24,030 --> 00:08:30,610 And what would what would we like to return to multiplied by the previous number? 101 00:08:30,900 --> 00:08:40,910 So that's the pill number, recursive four and minus one, plus pill no, recursive four and minus two. 102 00:08:41,220 --> 00:08:43,650 So that's basically the recursive call. 103 00:08:44,680 --> 00:08:52,570 So once again, guys, what what can we see now on the screen, basically we created a function that 104 00:08:52,570 --> 00:08:54,300 is called PILT, no recursive. 105 00:08:54,640 --> 00:09:01,990 And you have to understand that when you when you using a recursions, one main thing that is happening 106 00:09:01,990 --> 00:09:10,300 behind the scenes is that you simply define a function that is capable of doing some task. 107 00:09:10,380 --> 00:09:14,830 OK, and what is this function is capable of doing? 108 00:09:15,100 --> 00:09:21,430 This function is capable of finding out the Pell number for a given index. 109 00:09:22,180 --> 00:09:31,060 And this index may be whatever natural, of course, which is greater or equal to zero or greater or 110 00:09:31,060 --> 00:09:31,890 equal to zero. 111 00:09:32,560 --> 00:09:41,680 And so these function, its main task and its main objective and its main functionalities to find the 112 00:09:41,680 --> 00:09:46,090 PIN number at index and how it does it, it doesn't matter. 113 00:09:46,120 --> 00:09:54,070 OK, so we know that if you want to find the pool number four, index three, then it's definitely going 114 00:09:54,070 --> 00:10:01,580 to be two multiplied by the pool number four index to plus index, bill number four, index one. 115 00:10:01,870 --> 00:10:06,580 So basically you are going to call this function over and over again. 116 00:10:06,580 --> 00:10:12,590 And you know that there is a function that knows to find a phone number for current index. 117 00:10:12,610 --> 00:10:17,570 So this index can be in minus one and it may be also in minus two. 118 00:10:17,650 --> 00:10:24,010 So these current function four, and it knows that it can use another function, which is the same function 119 00:10:24,010 --> 00:10:28,170 for another index, and it will take care of these computations. 120 00:10:28,300 --> 00:10:36,760 So hopefully these explanation and kind of additional demonstration is clear to you is how to maybe 121 00:10:36,760 --> 00:10:39,190 look at this recursion concept. 122 00:10:40,950 --> 00:10:48,840 And with that being said, let us proceed to the non recursive solution, just if you like to summarize 123 00:10:49,170 --> 00:10:52,850 the topic of Pells sequences. 124 00:10:53,310 --> 00:11:01,440 So regarding the non recursive, what do you think should be done by the video in return once you have 125 00:11:01,440 --> 00:11:02,040 a solution? 126 00:11:02,040 --> 00:11:04,140 And we are going to do that together. 127 00:11:04,970 --> 00:11:11,660 All right, so now once you're back, basically I'm going to copy these signature of the function because 128 00:11:11,930 --> 00:11:16,280 it's going to be pretty much the same, just the name is going to be changed. 129 00:11:16,310 --> 00:11:18,020 So let's just add pail. 130 00:11:18,020 --> 00:11:19,940 No, not recursive. 131 00:11:20,680 --> 00:11:27,350 OK, so getting in and, you know, basically it's going to be once again, similar to one of our previous 132 00:11:27,350 --> 00:11:28,120 exercises. 133 00:11:29,180 --> 00:11:34,420 We are going to say are let's start with the two biggest cases. 134 00:11:34,430 --> 00:11:38,810 So let's just copy it, because it's pretty much the same thing, right? 135 00:11:39,860 --> 00:11:48,320 If if if so, if an equal to zero return zero equals to one return one, you know, what we will start 136 00:11:48,320 --> 00:11:53,630 is the next index that is not on the list of our base cases. 137 00:11:54,200 --> 00:12:00,770 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 138 00:12:00,770 --> 00:12:09,950 said and I and let's create also and I don't know in previous and current. 139 00:12:11,500 --> 00:12:14,770 OK, maybe we can also initialize them. 140 00:12:14,990 --> 00:12:20,950 OK, so the previous will be equal to zero and the current will equal to one because the previous I 141 00:12:21,040 --> 00:12:25,890 read here, the other end equals zero in the current four and equals to one. 142 00:12:25,900 --> 00:12:30,570 So that's why the R values are zero and one zero and one. 143 00:12:31,600 --> 00:12:39,040 And I'm going to start the for loop for I equals to two since I know I can use both the previous and 144 00:12:39,040 --> 00:12:42,030 current to calculate the next value. 145 00:12:42,040 --> 00:12:48,460 OK, because we know that this will be the current, this will be the previous and both of them will 146 00:12:48,460 --> 00:12:51,340 be used to calculate the next one. 147 00:12:51,430 --> 00:12:59,350 OK, so four equals to two that the initialization phase I as long as I is less than or equal to an 148 00:12:59,770 --> 00:13:00,730 I plus plus. 149 00:13:00,970 --> 00:13:03,430 OK, very simple for a loop. 150 00:13:03,640 --> 00:13:05,590 We are going to use iterations here. 151 00:13:06,760 --> 00:13:14,080 OK, and now what we'll also create is basically additional variable that's created. 152 00:13:14,080 --> 00:13:14,690 I don't know. 153 00:13:14,850 --> 00:13:16,160 Um hmm. 154 00:13:16,810 --> 00:13:17,950 What should we call it. 155 00:13:18,220 --> 00:13:20,830 Let's call this variable just for simplicity. 156 00:13:20,830 --> 00:13:21,820 Let's call it the. 157 00:13:21,950 --> 00:13:27,240 OK, so they stay or maybe next year. 158 00:13:27,280 --> 00:13:27,640 Next. 159 00:13:27,640 --> 00:13:28,610 Let's call it next. 160 00:13:28,690 --> 00:13:30,230 OK, so let's call it next. 161 00:13:30,790 --> 00:13:39,400 So this next is going to be equal to what do these calculations over the next value equals to two times 162 00:13:39,520 --> 00:13:42,910 multiplied by the current occurrence so far. 163 00:13:42,910 --> 00:13:45,520 Is this M minus one plus. 164 00:13:45,880 --> 00:13:46,660 Plus what. 165 00:13:47,050 --> 00:13:48,700 Plus the previous value. 166 00:13:49,270 --> 00:13:49,720 OK. 167 00:13:51,400 --> 00:13:58,390 And also, what we are going to do is to say now that previous, which was P and minus one, should 168 00:13:58,390 --> 00:14:01,980 now be the PM PM right. 169 00:14:03,250 --> 00:14:03,940 One second. 170 00:14:03,940 --> 00:14:10,060 And the previous the previous, which was P and minus two, should be now P and minus one. 171 00:14:10,060 --> 00:14:13,060 So previous equals to current. 172 00:14:13,400 --> 00:14:20,490 OK, and finally also we have to move the current also one further using the index. 173 00:14:20,500 --> 00:14:28,780 So the current will be equal to what do the next OK to the next in this iteration because the next on 174 00:14:28,780 --> 00:14:33,130 the next iteration is going to use the previous next to calculate it. 175 00:14:33,130 --> 00:14:33,430 Right. 176 00:14:34,090 --> 00:14:37,980 So that's basically it for this solution. 177 00:14:37,990 --> 00:14:38,470 Of course. 178 00:14:38,470 --> 00:14:45,460 Return finally, once you're done, return the correct current or next whatever comes to your mind, 179 00:14:45,460 --> 00:14:49,210 because both of them will have the same solutions, the same value. 180 00:14:49,240 --> 00:14:50,890 So return next in this case. 181 00:14:51,880 --> 00:14:56,920 And one thing to mention, guys, if you still have any questions, of course, feel free to ask them. 182 00:14:57,280 --> 00:15:07,810 Of course, regarding these non recursive approach, maybe, maybe, maybe, maybe another naming conventions 183 00:15:07,810 --> 00:15:10,210 maybe used for the previous and the current. 184 00:15:10,210 --> 00:15:14,170 They maybe maybe they are a little bit confusing. 185 00:15:14,680 --> 00:15:20,320 So you may always use like, I don't know, let's call it on. 186 00:15:21,040 --> 00:15:22,440 Let's call it previous. 187 00:15:22,840 --> 00:15:31,190 OK, you can call it as you can call it is previous and this will be like pre previous. 188 00:15:31,210 --> 00:15:40,930 OK, so previous will be minus one and pre previous will be and minus two, so are previous and next 189 00:15:40,930 --> 00:15:41,680 will be current. 190 00:15:41,710 --> 00:15:50,170 OK, I'm just giving you the same solution just with, with a dish, basically different variables, 191 00:15:50,290 --> 00:15:50,900 names. 192 00:15:50,920 --> 00:15:57,970 OK, so maybe it will be a little bit easier to use so that the current value is calculated by multiplying 193 00:15:57,970 --> 00:16:03,880 two times the previous plus one time the pre previous, which is this one. 194 00:16:04,000 --> 00:16:11,620 OK, and then you say like previous are three previous will be equal to previous. 195 00:16:12,280 --> 00:16:27,730 OK, this means that the value of P and minus two, um that the value of P and minus two will be equal 196 00:16:27,730 --> 00:16:29,890 to P and minus one. 197 00:16:29,890 --> 00:16:36,640 In this case these duration and the current will be equal to the current. 198 00:16:36,640 --> 00:16:40,060 What you should be will do should be equal to previous. 199 00:16:40,090 --> 00:16:46,780 OK, so three previous should be equal to current. 200 00:16:48,040 --> 00:16:55,470 OK, so guys basically basically I just changed the naming. 201 00:16:55,480 --> 00:17:00,430 I hope I did everything right here because we needed kind of quickly just to demonstrate. 202 00:17:01,210 --> 00:17:07,090 But I think you got the concept of how Paille sequences work, what they are, when they should be used 203 00:17:07,090 --> 00:17:07,720 and so on. 204 00:17:08,650 --> 00:17:11,410 And if you still have any questions, feel free to ask them. 205 00:17:11,660 --> 00:17:14,900 And of course, I will see you in the next videos. 206 00:17:14,920 --> 00:17:17,180 So until then, have a great time. 207 00:17:17,350 --> 00:17:19,400 My name is Vlad Alphatech. 208 00:17:19,420 --> 00:17:20,050 See you then. 20212

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