1 00:00:01,040 --> 00:00:02,960 Hello, everyone, welcome to this recession. 2 00:00:02,990 --> 00:00:08,360 So in today's session, what we will do, we will try to solve one more problem with the help of regulation. 3 00:00:08,360 --> 00:00:10,340 So the name of the problem is some of that. 4 00:00:10,350 --> 00:00:11,050 It's OK. 5 00:00:12,980 --> 00:00:14,770 Then the problem is some of digits. 6 00:00:15,140 --> 00:00:16,160 So what is the problem? 7 00:00:16,190 --> 00:00:21,070 So the problem is very simple, given the value of let's say it is one, two, three, four and five. 8 00:00:21,080 --> 00:00:23,600 But we have to do we have to add all these numbers. 9 00:00:24,140 --> 00:00:25,490 So the will be 15. 10 00:00:25,520 --> 00:00:26,810 So this is our answer. 11 00:00:26,840 --> 00:00:33,870 OK, so we have to add all the digits of the number and OK to leave the number and is 13 and answer 12 00:00:33,920 --> 00:00:39,800 will be three plus one for if the value of and is equal to plus one which is three. 13 00:00:40,130 --> 00:00:43,160 OK, so I hope you down sort of the value of this five. 14 00:00:43,160 --> 00:00:44,360 The answer will be five. 15 00:00:44,540 --> 00:00:47,630 If the value of and is zero then the answer will be zero. 16 00:00:47,750 --> 00:00:53,630 OK, so what we have to do, we have to add all the digits of the number and OK. 17 00:00:53,840 --> 00:00:55,500 And then we have to return the sum. 18 00:00:56,120 --> 00:01:00,500 OK, so we have already solved this problem addictively using the four will develop. 19 00:01:00,650 --> 00:01:06,080 But now in today's session, since we are learning regression, we will try to solve the same problem 20 00:01:06,080 --> 00:01:07,190 with the help of recursion. 21 00:01:07,250 --> 00:01:10,100 OK, so what resurgency is the answer is? 22 00:01:10,610 --> 00:01:15,010 I will I will come down with a small problem and you do the calculation. 23 00:01:15,200 --> 00:01:17,150 So what you will do. 24 00:01:17,750 --> 00:01:24,450 So we have to find some of the digits of no single digit of the net number. 25 00:01:24,710 --> 00:01:26,630 OK, so what will do? 26 00:01:26,630 --> 00:01:27,590 The case will say. 27 00:01:29,000 --> 00:01:32,110 So what I will do, I will break the problem into smaller part. 28 00:01:32,740 --> 00:01:35,480 OK, I will collocation on this part. 29 00:01:36,550 --> 00:01:38,350 And the question will give me the answer. 30 00:01:38,890 --> 00:01:40,420 So what would answer the question? 31 00:01:40,440 --> 00:01:45,670 Well, give me that answer for all the small problems then, so, you know, the smaller answer, how 32 00:01:45,670 --> 00:01:50,560 you will calculate the bigger answer, which I will do, smaller answer plus the last digit. 33 00:01:50,920 --> 00:01:52,690 OK, so this is last digit. 34 00:01:53,200 --> 00:01:56,480 So smaller surplus, last digit will be our answer. 35 00:01:56,500 --> 00:01:59,380 So 10 plus five, which will be 15. 36 00:02:00,220 --> 00:02:04,480 OK, similarly now how it will work in Benally. 37 00:02:04,720 --> 00:02:07,000 So so this is our number. 38 00:02:08,180 --> 00:02:10,789 OK, let's make the whole cauldron. 39 00:02:10,820 --> 00:02:16,220 So what will happen, I will break the smaller part, I will collocation on this part. 40 00:02:18,280 --> 00:02:21,400 Then this is our number one, two, three, four. 41 00:02:22,340 --> 00:02:25,040 I will call dedication on a smaller project. 42 00:02:27,350 --> 00:02:30,680 Again, I will call it a collision on this smaller part. 43 00:02:31,850 --> 00:02:35,090 Again, I will call the occasion on smaller part. 44 00:02:36,760 --> 00:02:41,880 And again, I will call the occasion on smaller part, so this is zero. 45 00:02:43,700 --> 00:02:46,110 So I'm calling regarding this smaller part. 46 00:02:46,130 --> 00:02:49,970 OK, so I am calling Alabama, so it will be zero. 47 00:02:50,270 --> 00:02:53,690 OK, and the value of and is zero, this is the smallest problem. 48 00:02:53,720 --> 00:02:55,880 So this will become our base case. 49 00:02:57,940 --> 00:02:59,260 So it will return zero. 50 00:03:00,460 --> 00:03:05,680 OK, so, Don, some of the smaller problem is zero, and then we have to add the last minute, so zero 51 00:03:05,680 --> 00:03:07,730 plus one, it will be one. 52 00:03:08,350 --> 00:03:11,260 Now, the answer with a smaller part is one. 53 00:03:11,380 --> 00:03:12,100 We have to work. 54 00:03:12,100 --> 00:03:14,650 The last version, which is two seven plus two is three. 55 00:03:16,310 --> 00:03:22,280 Now, the answer for the smaller part is three, now we have to share the last digit, so three plus 56 00:03:22,280 --> 00:03:23,420 three is six. 57 00:03:24,610 --> 00:03:27,920 Now, the answer for the smaller parties came out to be six. 58 00:03:28,270 --> 00:03:31,810 Now we have to add the last budget, so six plus four, which is 10. 59 00:03:32,990 --> 00:03:36,230 Now, the answer for the smaller part came out to be 10. 60 00:03:36,450 --> 00:03:39,920 Now we have to add the last budget to calculate the bigger problem. 61 00:03:40,670 --> 00:03:43,130 So 10 plus five, it will be 15. 62 00:03:43,360 --> 00:03:46,540 OK, so I hope by now will we know the formula. 63 00:03:46,790 --> 00:03:54,830 So if you want to calculate some of and what we have to do, so some will be a function, it will take 64 00:03:54,830 --> 00:03:59,120 a number and as input and it will give me the sum of the digits. 65 00:03:59,270 --> 00:04:03,110 OK, what I will do, I will give the sum function, the smaller problem. 66 00:04:03,140 --> 00:04:04,430 So this value is. 67 00:04:04,730 --> 00:04:05,740 And by 10. 68 00:04:06,440 --> 00:04:09,790 OK, so this will be what I will do. 69 00:04:09,800 --> 00:04:14,900 I will call, I will call the same function sum and I will give Smolla problem. 70 00:04:14,900 --> 00:04:18,279 I will give number by 10 smaller problem. 71 00:04:18,500 --> 00:04:20,180 So I'm giving this as input. 72 00:04:20,870 --> 00:04:24,410 So some will give me the output for the smaller problem. 73 00:04:24,410 --> 00:04:27,890 And now what we have to do, we have to add the last digit. 74 00:04:27,980 --> 00:04:30,740 OK, so I will add the last digit. 75 00:04:32,150 --> 00:04:34,310 OK, so I'm adding the last digit. 76 00:04:37,430 --> 00:04:42,810 OK, I am writing the last digit now let us write the code and then we will do, then we will try it 77 00:04:42,890 --> 00:04:45,110 again and we will again make the diagram, OK? 78 00:04:46,590 --> 00:04:51,720 So first of all, that they will be in danger, we have to return to some, let's say, the name of 79 00:04:51,720 --> 00:04:56,130 the function someone and what it does, it will take a number as inpart. 80 00:04:57,150 --> 00:05:02,490 And now the base case, so basically it's very simple, the smallest problem or solution we know. 81 00:05:02,550 --> 00:05:06,630 OK, so the value of zero, obviously, the sum will be zero. 82 00:05:07,560 --> 00:05:09,660 OK, so this is our base case. 83 00:05:12,150 --> 00:05:16,380 OK, so this is a case now it's time for the recursive case, OK? 84 00:05:17,690 --> 00:05:20,000 So let's write a recursive case. 85 00:05:21,490 --> 00:05:25,290 So for the recursive case, what will be our small answer? 86 00:05:26,440 --> 00:05:31,120 So our small answer will be very simple, so small answer will be. 87 00:05:32,970 --> 00:05:36,370 Calculate the answer for everything, OK? 88 00:05:36,720 --> 00:05:38,970 And now our calculation part. 89 00:05:40,230 --> 00:05:44,430 So for calculation part, what we have to do, we have to find out the last digit first. 90 00:05:50,080 --> 00:05:52,360 OK, so for calculation, what we have to do. 91 00:05:53,280 --> 00:05:54,660 What is our last digit? 92 00:05:57,840 --> 00:06:03,210 So we're calculating the last budget, I can do something like this and more tonight, so with the help 93 00:06:03,210 --> 00:06:08,340 of this court, I will get the last budget and then what I have to do, I have to return. 94 00:06:08,350 --> 00:06:11,340 Small answer plus last digit. 95 00:06:12,490 --> 00:06:17,080 OK, now let's call this function like let's call the function. 96 00:06:19,400 --> 00:06:23,000 And let us give the relevant two, three, four, five as input. 97 00:06:23,030 --> 00:06:26,030 OK, so what we said our answer will be 15. 98 00:06:27,960 --> 00:06:29,790 OK, so let's let this file. 99 00:06:32,280 --> 00:06:35,700 So our answer is coming out to 15, our gold is working fine. 100 00:06:36,210 --> 00:06:39,380 Let us try to make the diagram again and see what's happening. 101 00:06:41,270 --> 00:06:46,730 OK, so the value of and is one, two, three, four, five, so this is our value, one, two, three, 102 00:06:47,390 --> 00:06:48,290 four and five. 103 00:06:49,960 --> 00:06:57,820 OK, so this is not close to zero, so I will come at this line and I will call for end by 10, so I 104 00:06:57,820 --> 00:06:59,710 will call one, two, three and four. 105 00:07:01,130 --> 00:07:06,800 And this function is waiting in line number 11 dysfunctionally, also be red line number 11, because 106 00:07:06,800 --> 00:07:08,300 it will call one, two, three. 107 00:07:09,350 --> 00:07:17,570 It will wait at line number 11, it will cauldwell, it will wait at line No.11, it will call one and 108 00:07:17,570 --> 00:07:20,840 it will wait at line number 11, it will call zero. 109 00:07:21,470 --> 00:07:22,370 So what will happen? 110 00:07:22,370 --> 00:07:23,330 It will return zero. 111 00:07:24,110 --> 00:07:26,150 So it is returning zero. 112 00:07:26,990 --> 00:07:31,340 OK, so the small answer, small answer is zero. 113 00:07:31,760 --> 00:07:35,660 Then I'm calculating the last digit, which is and more than the value of this one. 114 00:07:35,690 --> 00:07:38,460 So one by 10, that will be one only. 115 00:07:38,510 --> 00:07:43,040 OK, so small and surplused last digit so zero plus one which is one. 116 00:07:43,310 --> 00:07:44,750 So I am returning one. 117 00:07:46,350 --> 00:07:50,830 OK, now here, the value of small answer is one. 118 00:07:51,080 --> 00:07:56,640 OK, so last digit and more 10 SAWTELL more than that will be two. 119 00:07:56,680 --> 00:07:59,160 OK, so the last digit is two. 120 00:07:59,520 --> 00:08:01,710 And then I'm returning the addition of these two. 121 00:08:01,720 --> 00:08:04,280 So to pleasantry, I'm returning three. 122 00:08:05,130 --> 00:08:10,530 Now, the value of small answer is three and then I'm calculating the last digit. 123 00:08:10,540 --> 00:08:12,770 So last digit is 123, more ten. 124 00:08:12,780 --> 00:08:18,120 So last digit is came out with three and then I'm returning the addition of these two. 125 00:08:18,120 --> 00:08:19,800 So three plus three, which is six. 126 00:08:20,770 --> 00:08:28,900 So I'm returning six small answers, six and last digit will be slow and more tense, a lot of it is 127 00:08:29,140 --> 00:08:29,680 this. 128 00:08:29,680 --> 00:08:30,850 This will be our last digit. 129 00:08:30,850 --> 00:08:31,990 So last as it is four. 130 00:08:32,500 --> 00:08:35,260 So six plus four, I'm returning the addition of these two. 131 00:08:35,559 --> 00:08:43,929 So I'm returning then and smile answers 10 and the last digit will be even more tense. 132 00:08:43,929 --> 00:08:45,460 So it will be five. 133 00:08:45,670 --> 00:08:47,820 And then I am returning the addition of these two. 134 00:08:47,830 --> 00:08:49,510 So 10 plus five, which is 15. 135 00:08:50,250 --> 00:08:53,980 OK, so that's how my answer is give out to be 15. 136 00:08:54,240 --> 00:08:56,700 OK, so I hope you have understood the code. 137 00:08:56,720 --> 00:08:58,000 So the code is very simple. 138 00:08:58,930 --> 00:09:02,110 We have to write the base case, then the recursive case. 139 00:09:02,230 --> 00:09:06,460 We have to calculate, we have to call the same function for a smaller input. 140 00:09:06,520 --> 00:09:08,680 OK, and then the calculation part. 141 00:09:08,920 --> 00:09:12,180 OK, so we are writing the code with the help of PMI only. 142 00:09:12,190 --> 00:09:14,790 OK, we are thinking about this diagram later. 143 00:09:15,160 --> 00:09:18,790 First we are thinking about this diagram later first. 144 00:09:20,270 --> 00:09:22,200 We are thinking only in terms of BMI. 145 00:09:22,220 --> 00:09:26,530 We have to think of three steps, Becka's recursive case and the calculation. 146 00:09:26,960 --> 00:09:31,850 OK, if you will write these three steps perfectly, then Nicole will definitely work. 147 00:09:32,330 --> 00:09:35,090 OK, so I hope you understood this problem. 148 00:09:35,300 --> 00:09:35,780 Thank you.