1
00:00:01,500 --> 00:00:03,500
Hello, everyone, welcome to this new session.

2
00:00:03,510 --> 00:00:08,900
So what we will do today, so we will try to solve one more problem with the help of the council so

3
00:00:08,910 --> 00:00:11,520
that our understanding of religion can become better.

4
00:00:11,550 --> 00:00:16,020
OK, so the name of the problem that we are going to solve today is multiplication.

5
00:00:16,410 --> 00:00:22,320
OK, so what we will do so given two numbers, we have to multiply them.

6
00:00:22,350 --> 00:00:27,570
OK, so there are two numbers, M and N and we have to multiply these two numbers.

7
00:00:27,600 --> 00:00:29,840
So that is M and doing OK.

8
00:00:30,000 --> 00:00:35,220
So the one way to solve this problem is to simply use the multiply operator, but we don't have to use

9
00:00:35,220 --> 00:00:36,170
multiply operator.

10
00:00:36,180 --> 00:00:38,100
We can only use an operator.

11
00:00:38,140 --> 00:00:41,490
OK, we can only use plus operator or minus operator.

12
00:00:41,690 --> 00:00:43,860
OK, we cannot use the multiply operator.

13
00:00:44,550 --> 00:00:47,650
Now I think we have to solve this problem but I'm not sure.

14
00:00:48,120 --> 00:00:52,200
So if you are multiplying two numbers and the end, can I write it like this.

15
00:00:52,210 --> 00:01:00,540
Basically I am adding the same number and times, ok, I am adding the same number and times.

16
00:01:00,750 --> 00:01:05,790
So we are using one lipless operator here so that the solution to the one solution for this problem

17
00:01:05,790 --> 00:01:14,010
is to just use a loop and that loop will run and times and inside the loop we will add Eminem.

18
00:01:14,190 --> 00:01:14,620
OK.

19
00:01:14,640 --> 00:01:19,160
So I think you can solve it very easily with the help of for a loop of a loop.

20
00:01:19,440 --> 00:01:22,320
But now we have to solve it using recursion.

21
00:01:22,400 --> 00:01:27,600
OK, so with the help of a loop, how you will solve you will keep a variable sum equals zero, you

22
00:01:27,600 --> 00:01:32,520
will run a loop and that group will run and times inside the loop.

23
00:01:32,520 --> 00:01:38,610
What we will do, you will write something like this simplistic to M and when the loop will be already

24
00:01:38,610 --> 00:01:39,600
you will return some.

25
00:01:39,890 --> 00:01:43,820
OK, so with the help of recursion, how we can solve this problem.

26
00:01:44,310 --> 00:01:44,760
So.

27
00:01:45,910 --> 00:01:47,680
We have to calculate Eman Duine.

28
00:01:48,780 --> 00:01:56,580
OK, let's say the value of M is five and let's say the value of industry, so our output will be 15

29
00:01:57,000 --> 00:01:58,860
to a. 15.

30
00:01:59,220 --> 00:02:00,600
OK, so.

31
00:02:01,490 --> 00:02:04,850
And in doing so, can I write Aminta in like.

32
00:02:06,070 --> 00:02:08,139
Multiply and minus one.

33
00:02:09,220 --> 00:02:11,860
Plus M can I write it like this?

34
00:02:13,620 --> 00:02:19,810
Yes, obviously, we can read it like this, this is nothing, but if you multiply inside this and then

35
00:02:19,830 --> 00:02:25,000
minus blessin and these two will cancel out, each others are totally Emman, OK.

36
00:02:25,230 --> 00:02:28,630
And so let's try it and how it will work.

37
00:02:28,670 --> 00:02:32,610
So in doing so, I want to calculate five into three.

38
00:02:32,910 --> 00:02:37,780
What I want to do here is multiply five with two and then add plus five.

39
00:02:37,950 --> 00:02:42,120
So the answer will be five into to that answer will be 15 only.

40
00:02:43,020 --> 00:02:47,140
OK, so basically what we're doing here is so five in total.

41
00:02:47,160 --> 00:02:51,570
This simply means five plus five plus five.

42
00:02:52,200 --> 00:02:53,130
So what we will do.

43
00:02:54,680 --> 00:03:01,640
I will tell recursion to solve this small problem and then I will add five, I will Erdem, OK, this

44
00:03:01,640 --> 00:03:07,130
is M, this is M and this is an OK, so I'm repeating myself.

45
00:03:09,750 --> 00:03:15,030
Let's take one more example, let's say the value of M is three and the value of and is five.

46
00:03:15,700 --> 00:03:19,170
OK, so I want to calculate them in doing so.

47
00:03:19,170 --> 00:03:23,400
Basically what we can do M plus M plus M, how many times.

48
00:03:24,240 --> 00:03:24,890
And Bems.

49
00:03:25,350 --> 00:03:25,770
OK.

50
00:03:28,760 --> 00:03:29,300
So.

51
00:03:30,450 --> 00:03:32,370
I want to multiply three to five.

52
00:03:33,410 --> 00:03:40,160
So I will add three, five times, so three plus three plus three plus three plus three.

53
00:03:40,640 --> 00:03:46,170
OK, so now what we will do, we will use the help of recursion, what we will use.

54
00:03:46,490 --> 00:03:49,310
So what we will do, we will break the problem into smaller problem.

55
00:03:49,340 --> 00:03:52,760
I will tell recursion to solve this part for me.

56
00:03:54,210 --> 00:04:00,860
And that equation will give me the answer and the answer will be 12 and then I will add em.

57
00:04:00,990 --> 00:04:06,690
OK, so this is M so the question will give me the answer, which is well, and then I will add.

58
00:04:06,690 --> 00:04:09,460
And so if I function multiply.

59
00:04:10,650 --> 00:04:11,770
So how does one multiply.

60
00:04:11,770 --> 00:04:16,050
A function will look like it will take to input as argument and then.

61
00:04:17,010 --> 00:04:25,020
What I will call I will call the same function multiply function for the smaller input, so I will tell

62
00:04:25,260 --> 00:04:26,640
you to give me the shut off.

63
00:04:27,360 --> 00:04:31,600
So what it will give me it will give me the answer off and multiply and minus one.

64
00:04:31,950 --> 00:04:35,610
OK, and this is in the end.

65
00:04:35,850 --> 00:04:40,440
And finally, what we will do, we will add after recursion will give me the answer.

66
00:04:40,440 --> 00:04:41,710
I will add this m.

67
00:04:42,780 --> 00:04:44,600
OK, so this will be our formula.

68
00:04:44,610 --> 00:04:47,670
This will be, this will be how that equation will look like.

69
00:04:48,040 --> 00:04:51,900
OK, now first let us write the code and then we will tighten the code.

70
00:04:52,050 --> 00:04:54,740
OK, so what will be our base case.

71
00:04:54,750 --> 00:04:56,580
So the base case will be very simple.

72
00:04:57,000 --> 00:04:58,410
You want to calculate Aminta.

73
00:04:58,410 --> 00:05:01,530
And so this case will be the value of Aniceto.

74
00:05:01,830 --> 00:05:04,770
Then if you multiply with zero then our good will be visit only.

75
00:05:04,800 --> 00:05:07,950
OK, if you multiply any number with zero, the output will be zero only.

76
00:05:08,010 --> 00:05:11,310
So this will be our base case if any zero return zero.

77
00:05:11,820 --> 00:05:15,100
OK, now first let us write the code and then we will try again.

78
00:05:15,160 --> 00:05:15,510
OK.

79
00:05:19,060 --> 00:05:26,650
So the return type will be integer and let's say the name of the function is multiply what it will take,

80
00:05:26,650 --> 00:05:29,530
it will take to integer as argumentum and then.

81
00:05:30,370 --> 00:05:34,570
OK, and what we have to calculate, we have to calculate and doing.

82
00:05:36,500 --> 00:05:37,640
We have to calculate.

83
00:05:38,710 --> 00:05:43,390
And in doing but without using multiply or pretend without for loop or loop.

84
00:05:43,440 --> 00:05:46,070
OK, now there is time for the base case.

85
00:05:46,530 --> 00:05:49,120
So the base case is the smallest problem or solution.

86
00:05:49,140 --> 00:05:49,720
We already know.

87
00:05:49,720 --> 00:05:54,570
So if the value of any zero so any number multiplied with zero will be zero only.

88
00:05:55,270 --> 00:05:56,370
So I will return zero.

89
00:05:57,590 --> 00:06:00,290
Now it's time for the recursive case, what we have to do.

90
00:06:01,400 --> 00:06:03,690
We have to solve the problem for the smaller input.

91
00:06:03,770 --> 00:06:08,840
OK, and what are the smaller and smaller and what is the value of and and minus one?

92
00:06:08,850 --> 00:06:09,230
So.

93
00:06:10,170 --> 00:06:11,070
Smiled and said.

94
00:06:12,780 --> 00:06:15,720
That's my answer is you have to I'm calling the same function.

95
00:06:17,270 --> 00:06:17,930
Multiply.

96
00:06:20,620 --> 00:06:24,400
And I want to calculate and do end minus one.

97
00:06:24,610 --> 00:06:29,320
OK, so at this lane, I have done set off Amerindo and minus one.

98
00:06:31,640 --> 00:06:36,860
And finally, our calculation part, so our calculation part is very simple.

99
00:06:37,890 --> 00:06:38,670
What we have to do.

100
00:06:39,910 --> 00:06:42,130
I will return this my answer.

101
00:06:43,280 --> 00:06:44,780
Plus M.

102
00:06:45,780 --> 00:06:49,530
And NetSol, OK, now let's call this function.

103
00:06:51,660 --> 00:06:57,390
So let's call this function and let us give the value of Immonen.

104
00:06:58,610 --> 00:06:59,780
So multiply.

105
00:07:01,580 --> 00:07:03,570
And have the values are three and five.

106
00:07:04,210 --> 00:07:04,610
OK.

107
00:07:06,590 --> 00:07:09,730
Now, if we learn this code, our output will be 15.

108
00:07:09,800 --> 00:07:10,190
OK?

109
00:07:11,710 --> 00:07:12,880
So let's send the file.

110
00:07:15,100 --> 00:07:18,540
So our output is coming out 15, basically, our goal is working fine.

111
00:07:18,600 --> 00:07:18,920
OK.

112
00:07:20,970 --> 00:07:23,010
So there is a big mistake here.

113
00:07:24,960 --> 00:07:28,460
OK, now let's try to understand how the output is coming out to 15.

114
00:07:28,500 --> 00:07:28,820
OK.

115
00:07:30,890 --> 00:07:32,510
So the values are three in five.

116
00:07:32,540 --> 00:07:35,240
OK, so we have three and we have five.

117
00:07:35,270 --> 00:07:36,840
So these are the values of Immonen.

118
00:07:37,180 --> 00:07:39,460
OK, so five is not close to zero.

119
00:07:40,550 --> 00:07:46,520
So basically, this function will wait at line number 10 and I call the function for Tecoma for.

120
00:07:48,030 --> 00:07:55,080
Again, this will be headline number 10 and I will call for three commentary, similarly, I will call

121
00:07:55,080 --> 00:07:56,100
for three two.

122
00:07:57,130 --> 00:08:02,800
Then I will call for triggermen and then I will call for Tecoma Zero.

123
00:08:04,010 --> 00:08:06,470
So the value of any zero return zero.

124
00:08:06,540 --> 00:08:13,310
OK, so basically this will return zero, so zero will be stored in this Moylan's so small answer becomes

125
00:08:13,310 --> 00:08:13,760
zero.

126
00:08:13,790 --> 00:08:15,360
I guess my answer becomes zero.

127
00:08:16,070 --> 00:08:18,260
Now I am returning small surplus.

128
00:08:18,260 --> 00:08:20,570
And what is the value of my value of a mystery.

129
00:08:21,050 --> 00:08:24,860
OK, so zero plus three that will be three.

130
00:08:26,770 --> 00:08:28,520
So my list of small answers.

131
00:08:28,600 --> 00:08:34,510
This is my answer, then I'm returning small surplus and the value of mystery only.

132
00:08:34,510 --> 00:08:36,370
So three plus three, which is six.

133
00:08:38,039 --> 00:08:42,690
So six is small and also six plus three, which is nine.

134
00:08:43,799 --> 00:08:47,910
OK, so small dancer becomes nine, then nine plus three.

135
00:08:48,950 --> 00:08:57,140
Basically, to so small answer is 12 and then 12 plus three, which is 15, OK, so 15 is our answer.

136
00:08:57,690 --> 00:09:00,080
OK, so that's how that equation is working.

137
00:09:00,760 --> 00:09:04,160
OK, so but you do not have to think all of this, OK.

138
00:09:04,490 --> 00:09:09,620
We will not think I love this, but I will think we will think like first.

139
00:09:09,620 --> 00:09:09,850
Right.

140
00:09:09,860 --> 00:09:11,150
The basic is very simple.

141
00:09:11,720 --> 00:09:14,330
Then write the recursive case.

142
00:09:14,570 --> 00:09:19,850
We will, we are calculating and with about minus one you have to assume, OK, you add line number

143
00:09:19,850 --> 00:09:20,170
10.

144
00:09:20,540 --> 00:09:26,360
What we are trying to do here is we are assuming that this multiplier function works, OK, this multiplier

145
00:09:26,360 --> 00:09:31,340
function, if if you will give to input as argument, it will give me Emmental and minus one.

146
00:09:31,550 --> 00:09:33,770
OK, you have to assume this, OK?

147
00:09:33,770 --> 00:09:35,600
You have to assume that this function will work.

148
00:09:36,700 --> 00:09:43,380
This dysfunction is working, at least give me the small answer I will add plus M to get to get our

149
00:09:43,380 --> 00:09:45,240
prop to get down to what the bigger problem.

150
00:09:45,480 --> 00:09:47,620
OK, and then we are turning our answer.

151
00:09:47,950 --> 00:09:51,640
OK, so first write the code, then think about the diagram.

152
00:09:51,660 --> 00:09:54,620
OK, first write the code and then go to the diagram.

153
00:09:54,630 --> 00:09:56,310
So I hope this problem is clear.

154
00:09:56,490 --> 00:09:58,010
If you have any doubt you can ask me.

155
00:09:58,050 --> 00:09:59,130
OK, thank you.

