1
00:00:02,870 --> 00:00:04,880
Hello, guys, and welcome back to the cause.

2
00:00:05,330 --> 00:00:10,700
In the last class, I introduce a concept called Lube, and I told you that the loops are very, very

3
00:00:10,700 --> 00:00:13,190
important and will be used throughout this course.

4
00:00:13,850 --> 00:00:19,430
So today, really solving six problems based on loops, because I want to make sure that the fundamentals

5
00:00:19,430 --> 00:00:20,540
are very, very strong.

6
00:00:20,900 --> 00:00:23,300
So I have divided six problems into two parts.

7
00:00:23,630 --> 00:00:25,670
Each part will consist of three problems.

8
00:00:26,050 --> 00:00:30,200
Padrón problems are easy and part two problems that are a little tough for beginner.

9
00:00:30,690 --> 00:00:30,900
OK.

10
00:00:31,190 --> 00:00:39,380
So let's begin part one problem one solve the problem statement is given an.

11
00:00:41,420 --> 00:00:45,080
We have to print all the numbers from where to win.

12
00:00:46,220 --> 00:00:54,280
Bentall, the numbers from one to N, for example, let's say the value of An is five.

13
00:00:54,740 --> 00:00:59,320
So now it butchered be one, two, three, four and five.

14
00:01:00,070 --> 00:01:07,240
Let's see the value of an is six star Bush would be one, two, three, four, five and six.

15
00:01:07,660 --> 00:01:12,130
Similarly to the value of an is to start Bush would be one and two.

16
00:01:12,550 --> 00:01:15,290
And if the value of this one so large, which would be one.

17
00:01:15,940 --> 00:01:19,420
So given n we have to print all the numbers from one to N.

18
00:01:20,200 --> 00:01:21,820
So how can we solve this problem?

19
00:01:22,600 --> 00:01:29,800
If you look carefully, we are printing five times to six times here, two times here and weren't done

20
00:01:29,800 --> 00:01:30,070
here.

21
00:01:30,190 --> 00:01:33,260
So we have to print any numbers starting from one to N.

22
00:01:34,210 --> 00:01:36,670
So we need a loop that will then end times.

23
00:01:37,090 --> 00:01:39,190
So the loop will look something like this.

24
00:01:39,850 --> 00:01:40,660
I equals one.

25
00:01:43,500 --> 00:01:45,420
Is a less than Articles two in.

26
00:01:47,970 --> 00:01:54,990
And then I will do some work here and then I will increment the value of I buy one and then I will check

27
00:01:54,990 --> 00:01:55,830
my condition again.

28
00:01:56,520 --> 00:02:02,010
So this loop will run and times via this loop is running and times because I initialize the value if

29
00:02:02,010 --> 00:02:04,460
I buy one and then I'm checking is a list and goes to.

30
00:02:04,830 --> 00:02:08,640
And at each time this loop is running, I am incrementing the value if I buy one.

31
00:02:09,000 --> 00:02:10,800
So this loop will run and times.

32
00:02:11,310 --> 00:02:13,350
So the first part of our problem statement is over.

33
00:02:13,440 --> 00:02:15,350
Now this loop will run and times.

34
00:02:16,230 --> 00:02:18,120
So we have to bring five numbers here.

35
00:02:18,150 --> 00:02:20,870
So this loop will in five times for an equals five.

36
00:02:21,130 --> 00:02:22,860
As a middle of the value of any equals six.

37
00:02:22,890 --> 00:02:24,420
This look will run six times.

38
00:02:25,020 --> 00:02:25,710
Now, what will I do?

39
00:02:25,740 --> 00:02:27,090
I will take a variable.

40
00:02:27,510 --> 00:02:28,980
Well, real means value.

41
00:02:29,430 --> 00:02:31,020
So initially my value is when.

42
00:02:31,770 --> 00:02:32,690
So what will I do here?

43
00:02:33,420 --> 00:02:34,440
I will print the value.

44
00:02:37,130 --> 00:02:37,480
Brent.

45
00:02:37,790 --> 00:02:40,830
Well, you and I will increment well by one.

46
00:02:41,170 --> 00:02:42,600
So liquids well past one.

47
00:02:43,960 --> 00:02:45,470
So initially, when will get printed?

48
00:02:45,750 --> 00:02:46,860
Then two will get printed.

49
00:02:46,890 --> 00:02:48,630
Then three will get printed and so on.

50
00:02:48,990 --> 00:02:55,620
So this little Bazzani and times and each time every print val and the value of Val will be increased

51
00:02:55,620 --> 00:02:56,190
by one.

52
00:02:56,220 --> 00:03:00,330
So next time this blueprinted and the next time table printed and so on.

53
00:03:00,540 --> 00:03:02,680
And the last end will be printed.

54
00:03:02,700 --> 00:03:04,320
And then my loop will terminate.

55
00:03:04,980 --> 00:03:06,150
My loop will break.

56
00:03:07,080 --> 00:03:08,370
So let us draw the flowchart.

57
00:03:13,850 --> 00:03:15,140
So I will start my flow chart.

58
00:03:17,220 --> 00:03:19,830
Then why do they do for running the loop and times?

59
00:03:19,890 --> 00:03:20,850
I will take a variable.

60
00:03:21,450 --> 00:03:29,160
And I really flies it to one and similarly I will DEGA Well which is when I will bring value.

61
00:03:29,940 --> 00:03:30,330
So.

62
00:03:31,560 --> 00:03:37,300
As I left and it goes to in this condition is used to run the loop and Bems.

63
00:03:39,690 --> 00:03:41,790
If this condition is true, what will I do?

64
00:03:41,880 --> 00:03:42,770
I will bring developed.

65
00:03:46,490 --> 00:03:49,040
And really grew in the well by van.

66
00:03:50,320 --> 00:03:51,650
So when equals.

67
00:03:52,170 --> 00:03:53,530
Well, plus when.

68
00:03:56,040 --> 00:04:01,440
And now I will being guaranteed why when as I want to run the loop for end times.

69
00:04:05,490 --> 00:04:10,950
So this loop will run and times because initially my eye equals one.

70
00:04:11,280 --> 00:04:14,240
And each time this loop is learning, I am granting the value.

71
00:04:14,310 --> 00:04:15,310
If I buy one.

72
00:04:15,690 --> 00:04:16,890
So I equals I plus one.

73
00:04:17,280 --> 00:04:19,050
So this loop will run and times.

74
00:04:19,380 --> 00:04:21,130
And each time I am printing well.

75
00:04:21,690 --> 00:04:23,540
And the value of well is increased by one.

76
00:04:24,180 --> 00:04:27,650
If this condition is false, I will simply end my program.

77
00:04:29,860 --> 00:04:30,130
OK.

78
00:04:30,640 --> 00:04:34,810
Let's take an example and I will try to show you how this is working.

79
00:04:37,400 --> 00:04:39,310
Let's say, and it goes five.

80
00:04:39,630 --> 00:04:39,890
OK.

81
00:04:41,620 --> 00:04:42,760
So N equals five.

82
00:04:45,250 --> 00:04:49,240
I started my program, I equals one valid question.

83
00:04:49,490 --> 00:04:49,800
OK.

84
00:04:50,500 --> 00:04:54,020
Is I less than it was doing so is one less than I close to five.

85
00:04:54,120 --> 00:04:55,270
Yes, the condition is true.

86
00:04:55,330 --> 00:04:56,020
I will go here.

87
00:04:57,550 --> 00:04:57,830
Brent.

88
00:04:58,100 --> 00:04:58,660
Well, OK.

89
00:04:58,750 --> 00:04:59,620
When will we printed?

90
00:05:00,880 --> 00:05:03,110
It gives the value of well, by when.

91
00:05:03,600 --> 00:05:09,680
So the new value of well is to OK, given the value, if I buy one to the new value, if I is to, then

92
00:05:09,690 --> 00:05:10,300
I am checking.

93
00:05:10,300 --> 00:05:14,250
The condition is to less than articles to five years.

94
00:05:14,250 --> 00:05:15,570
Yes, the condition is true, Brent.

95
00:05:15,710 --> 00:05:16,450
Well OK.

96
00:05:16,530 --> 00:05:22,180
To leap into the new value of well is three and Grendell if I buy one.

97
00:05:22,660 --> 00:05:25,810
So it's two less than it was when we had the condition is true.

98
00:05:26,110 --> 00:05:28,750
So tabouli reprinted in the value.

99
00:05:28,870 --> 00:05:29,760
Well by one.

100
00:05:29,830 --> 00:05:31,210
So the new value of well is for.

101
00:05:31,300 --> 00:05:34,660
And similarly the new interface for so is for less than I to.

102
00:05:35,230 --> 00:05:35,530
Yes.

103
00:05:35,560 --> 00:05:36,190
Print for.

104
00:05:36,720 --> 00:05:44,860
And similarly print five and then my I will become six and six is not less than articles to five.

105
00:05:44,920 --> 00:05:46,240
So this condition is false.

106
00:05:46,630 --> 00:05:48,780
And I will come here and I will end my program.

107
00:05:49,090 --> 00:05:51,250
And this is my output which is hundred percent correct.

108
00:05:51,940 --> 00:05:53,110
If you have look carefully.

109
00:05:53,220 --> 00:05:55,180
There is no need of when.

110
00:05:56,930 --> 00:05:58,150
I am repeating myself.

111
00:05:58,480 --> 00:06:02,530
If you look carefully, there is no need of variable van.

112
00:06:03,840 --> 00:06:09,450
Basically, I and well are equal I and well are equal.

113
00:06:09,600 --> 00:06:10,320
Look carefully.

114
00:06:10,590 --> 00:06:16,170
Initially, both are initialized to one that I'm printing well and then guarantee the value of well

115
00:06:16,170 --> 00:06:18,720
by one similar name granting the value if I buy one.

116
00:06:19,080 --> 00:06:21,290
What can I do here instead of printing.

117
00:06:21,540 --> 00:06:25,160
I will print I because I end when I see him, I will print.

118
00:06:25,740 --> 00:06:27,540
And similarly, there is no need of this block.

119
00:06:27,750 --> 00:06:31,920
I will simply if there are, if I buy one, just like I am increasing the value of men by one.

120
00:06:32,550 --> 00:06:34,400
So let us know the updated flowchart.

121
00:06:36,700 --> 00:06:38,040
So I will start my program.

122
00:06:40,940 --> 00:06:45,160
They will only take a single variable line, which is initialized to one.

123
00:06:45,670 --> 00:06:50,530
Then I will let the male Lupron for and times because we have to print and numbers.

124
00:06:52,040 --> 00:06:53,600
So this conditional limit to initially.

125
00:06:55,120 --> 00:06:55,770
I will print.

126
00:06:55,930 --> 00:07:00,150
I hear instead of printing one, because I it will contain the same value.

127
00:07:00,820 --> 00:07:03,320
Then I will simply increment the value if I buy one.

128
00:07:04,030 --> 00:07:05,650
And then I will check the condition again.

129
00:07:06,060 --> 00:07:09,530
And similarly here, I'll be having false and end.

130
00:07:11,300 --> 00:07:11,550
Okay.

131
00:07:11,670 --> 00:07:14,050
Let us run this code for an example.

132
00:07:17,710 --> 00:07:21,160
Let's say let's say N equals three.

133
00:07:22,000 --> 00:07:23,030
So I start my program.

134
00:07:23,590 --> 00:07:28,670
I take a variable eight, which is initialized to one that I'm checking is one less than English.

135
00:07:28,690 --> 00:07:29,140
Two, three.

136
00:07:29,200 --> 00:07:30,100
So the condition is true.

137
00:07:30,130 --> 00:07:30,880
So I will come here.

138
00:07:32,350 --> 00:07:32,630
A..

139
00:07:33,210 --> 00:07:35,810
When we liberated in Greece there ayliffe, I buy one.

140
00:07:35,880 --> 00:07:38,850
So the new really if I is to OK then I will come here.

141
00:07:40,280 --> 00:07:42,890
Is to less than to so the condition is true, I will come here.

142
00:07:43,160 --> 00:07:46,790
Brent, I will have rendered increase the value if I buy one.

143
00:07:46,820 --> 00:07:49,300
So the new value if I is three is still less than it was two.

144
00:07:49,300 --> 00:07:49,490
Three.

145
00:07:49,540 --> 00:07:49,670
Yes.

146
00:07:49,670 --> 00:07:50,450
The condition is true.

147
00:07:50,460 --> 00:07:52,490
You will three after printing.

148
00:07:52,490 --> 00:07:54,770
Three after printing I, I will check.

149
00:07:55,640 --> 00:07:56,000
Sorry.

150
00:07:56,060 --> 00:07:58,760
I will increase the value if I buy one to the new value if I is four.

151
00:07:59,060 --> 00:08:00,420
So it is for less than ogles.

152
00:08:00,430 --> 00:08:00,690
Two, three.

153
00:08:00,770 --> 00:08:04,970
So the condition is false and you will come here and you will end my program.

154
00:08:05,300 --> 00:08:07,710
And the two terms went to three is printed.

155
00:08:08,270 --> 00:08:09,950
So that is hundred percent correct.

156
00:08:10,610 --> 00:08:12,110
So there is no need of variable.

157
00:08:12,230 --> 00:08:13,730
Well if you are taking a variable.

158
00:08:13,730 --> 00:08:15,170
Well today's notion that.

159
00:08:15,550 --> 00:08:17,150
But there is actually no need.

160
00:08:18,380 --> 00:08:18,610
Okay.

161
00:08:18,650 --> 00:08:22,380
So it doesn't waste what the question was, the question was given.

162
00:08:22,410 --> 00:08:27,680
And we have to print all the numbers from one to and basically we have to print and times starting from

163
00:08:27,680 --> 00:08:27,920
when.

164
00:08:29,240 --> 00:08:34,110
So here you seeds are my example, if anyone thinks we are printing six time, if any clues do we have

165
00:08:34,110 --> 00:08:35,510
printing two thumbs and so on.

166
00:08:36,230 --> 00:08:37,550
So initially, what was our approach?

167
00:08:38,120 --> 00:08:39,290
Our approach was very simple.

168
00:08:39,320 --> 00:08:44,690
I will take a variable eye and let this Lupron for N times because we have to print and numbers.

169
00:08:44,780 --> 00:08:49,310
So the loop will run and times how this loop is running and times I am taking a very well I which is

170
00:08:49,320 --> 00:08:50,060
initialized to one.

171
00:08:50,180 --> 00:08:52,880
And each time this loop is running, I am grinding the way.

172
00:08:53,020 --> 00:08:53,600
If I buy one.

173
00:08:53,630 --> 00:08:57,740
So this loop will end and times simple and I will do some work here.

174
00:08:57,890 --> 00:08:59,810
So the work is to print numbers.

175
00:09:00,050 --> 00:09:01,050
So overprinting numbers.

176
00:09:01,190 --> 00:09:04,910
What I did, I took a variable will and I will print.

177
00:09:04,960 --> 00:09:05,900
Well, each time.

178
00:09:06,020 --> 00:09:08,960
And after printing that one, I will increase the value of well by one.

179
00:09:09,480 --> 00:09:09,980
Simple.

180
00:09:10,640 --> 00:09:14,630
So Hayes the first version of our flowchart.

181
00:09:15,290 --> 00:09:16,820
So what I did start my program.

182
00:09:16,850 --> 00:09:17,650
Take two variable.

183
00:09:17,730 --> 00:09:19,010
I end well initially.

184
00:09:19,010 --> 00:09:20,390
Both are initialized to one.

185
00:09:20,630 --> 00:09:21,760
Then my loop is ending.

186
00:09:21,860 --> 00:09:22,670
End times.

187
00:09:23,510 --> 00:09:25,280
Each time I'm printing when.

188
00:09:25,340 --> 00:09:26,830
And incrementing the value of Val.

189
00:09:26,930 --> 00:09:27,500
By one.

190
00:09:28,190 --> 00:09:29,420
So this will be simple flow.

191
00:09:29,430 --> 00:09:32,960
And then I told you there is no need of Vallandigham because they are equal.

192
00:09:35,160 --> 00:09:41,100
So you start your program, you took a equals one, and this law will run and times.

193
00:09:42,290 --> 00:09:46,910
Each time you are sprinting, I saw one, two, three, four, and of course, three will get printed.

194
00:09:47,690 --> 00:09:49,370
OK, so let us all learn the problem.

195
00:09:55,810 --> 00:09:56,540
Problem to.

196
00:09:58,150 --> 00:09:59,440
So the verbal statement is.

197
00:10:01,390 --> 00:10:02,080
Given an.

198
00:10:03,430 --> 00:10:04,420
You have to check.

199
00:10:06,960 --> 00:10:07,490
It is.

200
00:10:09,240 --> 00:10:09,690
Brime.

201
00:10:10,840 --> 00:10:11,340
Or not.

202
00:10:11,940 --> 00:10:12,150
OK.

203
00:10:12,210 --> 00:10:15,070
So first of all, what type prime numbers, prime numbers are.

204
00:10:15,090 --> 00:10:15,720
Those numbers.

205
00:10:15,750 --> 00:10:17,370
And that has only two factors.

206
00:10:17,790 --> 00:10:19,340
One and itself.

207
00:10:20,220 --> 00:10:24,480
For example, if the value of an is five star, output should be prime.

208
00:10:25,680 --> 00:10:25,920
Why?

209
00:10:26,040 --> 00:10:28,020
Because five has only two factors.

210
00:10:28,290 --> 00:10:29,820
One and itself.

211
00:10:31,110 --> 00:10:34,740
Similarly, if the value of an is seven, the output should be prime.

212
00:10:35,470 --> 00:10:40,200
There was seven is also a prime number one and seven are two factors.

213
00:10:40,560 --> 00:10:45,280
If the value of an is let's say it so it is not prime to the output.

214
00:10:45,280 --> 00:10:46,170
Should be Nordström.

215
00:10:48,170 --> 00:10:49,220
It has many factors.

216
00:10:49,290 --> 00:10:51,620
One, two, four and eight.

217
00:10:51,770 --> 00:10:54,320
More than two factors means that number is not prime.

218
00:10:55,620 --> 00:10:55,920
OK.

219
00:10:56,370 --> 00:10:57,930
So what should be our approach?

220
00:10:59,670 --> 00:11:02,720
So we are going to follow very simple approach, the limited approach.

221
00:11:03,510 --> 00:11:07,620
What will I do starting from the tail end minus one?

222
00:11:13,680 --> 00:11:18,190
So when and and these are going to be the factors.

223
00:11:18,660 --> 00:11:19,530
So what will I do?

224
00:11:20,040 --> 00:11:28,920
My approach will be if I'm able to find any factor, any number between two, two and minus one that

225
00:11:28,920 --> 00:11:31,410
divides and then the number is not prime.

226
00:11:32,850 --> 00:11:33,170
OK.

227
00:11:33,410 --> 00:11:34,510
I am repeating myself.

228
00:11:35,080 --> 00:11:42,130
So my logic will be I have to find one number, just one number from two, two and minus one.

229
00:11:42,400 --> 00:11:50,110
If I am able to find just one single number that divides and then the number is nought prime.

230
00:11:50,440 --> 00:11:52,240
Otherwise, the number is prime.

231
00:11:53,270 --> 00:11:54,140
I'll get one more time.

232
00:11:54,560 --> 00:11:57,230
So we have to find the numbers prime or not.

233
00:11:57,740 --> 00:12:03,020
So I'm telling you one and and these two are going to be the.

234
00:12:03,490 --> 00:12:04,110
There must.

235
00:12:04,530 --> 00:12:05,710
They are going to be defectors.

236
00:12:05,900 --> 00:12:06,860
What is my approach?

237
00:12:07,370 --> 00:12:09,980
Starting from two to N minus one.

238
00:12:10,370 --> 00:12:12,800
I have to just find a single number.

239
00:12:14,040 --> 00:12:14,670
That divides.

240
00:12:14,790 --> 00:12:20,870
And if I'm able to find just one single number that divides and then my work is over and the number

241
00:12:20,870 --> 00:12:21,550
is not prime.

242
00:12:21,900 --> 00:12:28,860
And if I'm not able to find any number from two, two and minus one, that means the number is prime.

243
00:12:30,060 --> 00:12:31,540
OK, so what will I do?

244
00:12:31,780 --> 00:12:32,890
I will simply run a loop.

245
00:12:33,520 --> 00:12:37,940
I will take a variable I which is initialize to two and I will run a loop.

246
00:12:39,010 --> 00:12:40,810
So how many times this loop will work?

247
00:12:42,180 --> 00:12:44,630
Then I is less than goes to N minus one.

248
00:12:46,950 --> 00:12:52,740
So I will take a variable eye, which is Orange likes to do, and I will run this loop till I is left

249
00:12:52,740 --> 00:12:54,040
and it goes to minus one.

250
00:12:54,370 --> 00:12:57,720
And at each time inside the loop, I will try to divide the number.

251
00:12:59,080 --> 00:13:04,450
By eye, if the number is divisible by eye, that means the number is.

252
00:13:05,490 --> 00:13:06,160
Nart Prime.

253
00:13:08,020 --> 00:13:14,210
And if the loop terminates, if the loop terminated, that means I have tried all the numbers starting

254
00:13:14,230 --> 00:13:15,970
from two to end, minus one.

255
00:13:16,240 --> 00:13:19,450
But I am not able to find even a single number that divides.

256
00:13:19,510 --> 00:13:23,320
And so that means if the loop steamier, that the number is prime.

257
00:13:25,760 --> 00:13:26,020
OK.

258
00:13:26,130 --> 00:13:27,090
So let us revise.

259
00:13:28,110 --> 00:13:33,810
So the question was we given and I have to check whether the number is prime or not.

260
00:13:34,440 --> 00:13:37,730
So we're not prime numbers, prime numbers must those number.

261
00:13:37,830 --> 00:13:39,210
That has only two factors.

262
00:13:39,400 --> 00:13:40,950
One and itself.

263
00:13:42,420 --> 00:13:47,430
For example, if the elephant is five, then the most plan, because it has only two factors, one and

264
00:13:47,430 --> 00:13:47,730
five.

265
00:13:48,330 --> 00:13:55,530
Similarly, the value of an is it therefore factors more than two factors means that the number is not

266
00:13:55,530 --> 00:13:55,850
prime.

267
00:13:57,550 --> 00:14:04,200
Okay, so I told you one is going to be a factor and is also going to effector.

268
00:14:04,830 --> 00:14:06,300
So my approach is very simple.

269
00:14:07,170 --> 00:14:09,780
I have to find just one single number.

270
00:14:09,870 --> 00:14:11,850
Starting from two, two and minus one.

271
00:14:12,120 --> 00:14:16,830
If I'm able to find just one single number that divides and then the number is not prime.

272
00:14:17,280 --> 00:14:20,010
And if I'm not able to find just one single number.

273
00:14:20,100 --> 00:14:21,420
And the number is prime.

274
00:14:22,050 --> 00:14:27,520
So I will take a variable eye which is initialized to two and I will run this loop till I is less than

275
00:14:27,520 --> 00:14:28,360
close to and minus one.

276
00:14:28,980 --> 00:14:33,230
And inside the loop, I will try to divide the number by I.

277
00:14:33,600 --> 00:14:36,630
And if the numbers do so by then, the number is not brime.

278
00:14:36,990 --> 00:14:38,670
Otherwise, if this loop terminates.

279
00:14:39,570 --> 00:14:42,540
That means the number is Priam because I have tested all the numbers.

280
00:14:42,600 --> 00:14:44,100
Starting from Doodoo and minus one.

281
00:14:44,130 --> 00:14:47,340
But I am not able to find just one single mother divides them.

282
00:14:47,460 --> 00:14:52,150
So that automatically means if the loop the minutes and the number is blank ocular destroy the flowchart

283
00:14:52,170 --> 00:14:52,650
for the same.

284
00:14:55,910 --> 00:14:57,190
So I will start my program.

285
00:14:59,910 --> 00:15:01,740
That was Embley at Reed and.

286
00:15:06,170 --> 00:15:07,280
OK, sorry, sorry, sorry.

287
00:15:07,610 --> 00:15:08,640
I did something wrong.

288
00:15:10,710 --> 00:15:11,770
Oh, man.

289
00:15:13,620 --> 00:15:14,760
There's a mistake here.

290
00:15:16,080 --> 00:15:16,950
So mistake is.

291
00:15:18,920 --> 00:15:22,560
I was the first to read in so many guys for the mistake.

292
00:15:22,920 --> 00:15:24,330
I don't know, Ohio, I go forward.

293
00:15:25,080 --> 00:15:26,460
So first you have to read and hear.

294
00:15:27,570 --> 00:15:28,350
Sorry again.

295
00:15:29,660 --> 00:15:32,120
And similarly, you have to read and hear first.

296
00:15:33,880 --> 00:15:34,090
Rude.

297
00:15:34,360 --> 00:15:37,080
And so any guys for the mistake?

298
00:15:40,420 --> 00:15:41,560
So you have to first read.

299
00:15:41,650 --> 00:15:47,740
And after reading, then you will take a variable eye, which is initialized to two.

300
00:15:49,910 --> 00:15:55,740
And we have to paste all the numbers from door to and minus and Sawtell I less than Anglo's to end minus

301
00:15:55,740 --> 00:15:55,950
one.

302
00:15:56,090 --> 00:15:56,900
I have to check.

303
00:15:57,500 --> 00:16:00,230
I have to find just one single number that divides.

304
00:16:00,710 --> 00:16:04,730
And so I'm checking if this condition is true.

305
00:16:04,880 --> 00:16:05,900
I will come here.

306
00:16:07,090 --> 00:16:10,570
Is and there is evil.

307
00:16:12,380 --> 00:16:20,240
By I if the numbers do well, by I, that means if this condition is true, that means my number is

308
00:16:20,240 --> 00:16:23,070
not prime, not from.

309
00:16:24,210 --> 00:16:27,750
And I will add and my program so and.

310
00:16:31,190 --> 00:16:32,780
And if this condition is false.

311
00:16:37,140 --> 00:16:38,880
I will go on the radio if I buy one.

312
00:16:40,450 --> 00:16:42,250
And then I will try to do it again.

313
00:16:43,860 --> 00:16:44,370
Simple.

314
00:16:44,430 --> 00:16:48,840
So this loop will check for close to two and minus one.

315
00:16:50,310 --> 00:16:53,610
So this loop Willdan from close to two and Magnuson's and right.

316
00:16:53,620 --> 00:16:54,800
If the condition is false.

317
00:16:56,400 --> 00:17:01,800
If this condition is was that means I have tested all the numbers from two, two and minus one.

318
00:17:02,580 --> 00:17:05,670
But I am not able to find just one single number that divides.

319
00:17:05,670 --> 00:17:10,230
And so that automatically means that the number is plain print.

320
00:17:11,300 --> 00:17:14,360
Prime and then I will end my program.

321
00:17:17,710 --> 00:17:18,940
OK, so there doesn't waste anywhere.

322
00:17:19,120 --> 00:17:19,600
We have done.

323
00:17:24,690 --> 00:17:27,930
So given then we have to check with our number is prime or not.

324
00:17:28,590 --> 00:17:31,500
For example, five is prime because there are two factors.

325
00:17:31,500 --> 00:17:32,430
Only one in five.

326
00:17:32,760 --> 00:17:33,460
Seven is prime.

327
00:17:33,510 --> 00:17:34,800
Because there are only two factors.

328
00:17:34,830 --> 00:17:35,490
One in seven.

329
00:17:35,820 --> 00:17:36,590
It is not right.

330
00:17:36,630 --> 00:17:38,490
Because there are more than two factors.

331
00:17:39,810 --> 00:17:41,070
So the approach is very simple.

332
00:17:41,430 --> 00:17:44,370
I will try to divide by two now and I will do it by two.

333
00:17:44,390 --> 00:17:46,460
Then I will try to divide my four, five, six.

334
00:17:46,530 --> 00:17:48,370
And keep going until and minus one.

335
00:17:49,170 --> 00:17:50,210
If I may.

336
00:17:50,210 --> 00:17:55,830
Well to find just one single number in these set of numbers that divides and that means the number is

337
00:17:55,830 --> 00:17:56,320
not prime.

338
00:17:56,760 --> 00:17:58,380
Otherwise the number is prime.

339
00:17:58,650 --> 00:17:59,820
So the logic of it is simple.

340
00:17:59,940 --> 00:18:03,720
So let us take an example into the value of and is three.

341
00:18:04,590 --> 00:18:06,340
So you start the program, right?

342
00:18:06,390 --> 00:18:10,050
Then I go to and the value of and minus one is.

343
00:18:11,280 --> 00:18:17,100
Do so is to less and close to do for the condition is true, you will come here is endives it by eight

344
00:18:17,190 --> 00:18:18,570
is too divisible by two.

345
00:18:18,900 --> 00:18:23,010
No, you will come here and go under hell if I Bevan's Venezuela if I is three.

346
00:18:25,790 --> 00:18:28,610
Is three less than I to do, so the condition is false.

347
00:18:28,670 --> 00:18:29,360
You will come here.

348
00:18:30,550 --> 00:18:33,530
And they will print prime and then you will end your program.

349
00:18:33,850 --> 00:18:37,360
So the output will be prime, which is hundred percent correct.

350
00:18:37,510 --> 00:18:41,140
Let's say an equals six to a program.

351
00:18:41,790 --> 00:18:45,580
Then I equals two and minus one is five.

352
00:18:45,700 --> 00:18:48,050
So Jack is two less than it was to face.

353
00:18:48,120 --> 00:18:49,000
The condition is true.

354
00:18:49,000 --> 00:18:52,550
You will come here is six Loserville by two.

355
00:18:52,750 --> 00:18:53,770
So the condition is true.

356
00:18:53,780 --> 00:18:56,290
You will come here, Brent, not brain.

357
00:18:56,390 --> 00:18:57,700
So in our primary we printed.

358
00:18:59,410 --> 00:19:04,120
And then you will endure program six is not a prime number.

359
00:19:04,540 --> 00:19:06,400
And I would put this hundred percent.

360
00:19:07,600 --> 00:19:08,840
OK, so let us all.

361
00:19:08,880 --> 00:19:12,430
And the problem and this problem is the last problem for part one.

362
00:19:14,280 --> 00:19:15,480
So problem number three.

363
00:19:16,530 --> 00:19:18,240
Last problem of Paduan.

364
00:19:18,660 --> 00:19:21,330
So the Brownlow's statement is given an.

365
00:19:23,690 --> 00:19:24,380
Fined.

366
00:19:25,990 --> 00:19:26,740
Some of.

367
00:19:28,560 --> 00:19:29,430
Even numbers.

368
00:19:31,000 --> 00:19:33,380
From one to end.

369
00:19:34,680 --> 00:19:38,580
For example, let's say the valley of and is six.

370
00:19:39,150 --> 00:19:44,310
So your answer should be two plus four plus six.

371
00:19:45,200 --> 00:19:49,410
Now, this plan, let's say the value of N is five.

372
00:19:49,800 --> 00:19:50,600
So large butchered.

373
00:19:51,270 --> 00:19:53,940
Your answer should be two plus four.

374
00:19:54,480 --> 00:19:57,990
That is six later and includes two.

375
00:19:58,410 --> 00:20:00,750
So her answer should be to.

376
00:20:01,790 --> 00:20:06,650
So given then we have to find some of even numbers from one to end.

377
00:20:06,860 --> 00:20:11,310
So for inequal six that here numbers from one, two, six, two, four and six.

378
00:20:11,780 --> 00:20:12,590
So add them all.

379
00:20:13,460 --> 00:20:16,100
Similarly, four and five for there only two numbers.

380
00:20:16,380 --> 00:20:18,580
Their daddy went from one to five, two and four.

381
00:20:18,660 --> 00:20:19,160
Add them.

382
00:20:19,550 --> 00:20:22,690
And frankly, two days, only one even number.

383
00:20:23,030 --> 00:20:24,810
So the answer is two.

384
00:20:25,590 --> 00:20:27,050
So how can we solve this problem?

385
00:20:28,410 --> 00:20:29,830
So we need a loop here.

386
00:20:30,850 --> 00:20:37,830
So my loop will start from my crystal and this loop will run for how many times till I.

387
00:20:37,890 --> 00:20:38,730
Is less than 10.

388
00:20:39,550 --> 00:20:45,080
And each time I will increment the value of I buy to why I'm giving the value if I buy two.

389
00:20:45,670 --> 00:20:48,100
Because we only have to consider even numbers.

390
00:20:48,460 --> 00:20:54,950
That's why I initialized my variable with two only, which is the first to a number from one to and.

391
00:20:56,190 --> 00:20:56,440
OK.

392
00:20:57,170 --> 00:20:59,400
So I will initialize the value if I do.

393
00:20:59,990 --> 00:21:04,880
Which is the first two and number from one to N and I will run a loop.

394
00:21:05,510 --> 00:21:07,550
And in the loop, I will do some work.

395
00:21:08,360 --> 00:21:14,720
And then I will increment the value of FI by two because we have to only consider even numbers.

396
00:21:15,850 --> 00:21:21,610
What is the work that I will do in the loop, but I will take a variable sum and I will initialize them

397
00:21:21,610 --> 00:21:29,020
to zero and in the loop, I will add I to the current sum.

398
00:21:31,210 --> 00:21:40,610
And I do the current sum that is no value of some as equals to oil value of some plus I.

399
00:21:43,020 --> 00:21:46,230
So this is the work that I will do in the loop.

400
00:21:47,810 --> 00:21:52,940
And then when my loop will break my on several being some, I will pinch some.

401
00:21:55,760 --> 00:21:56,750
It is the flowchart.

402
00:21:56,890 --> 00:21:58,600
You will get a better understanding from the.

403
00:22:02,990 --> 00:22:04,170
So we start our flowchart.

404
00:22:05,600 --> 00:22:07,310
And then I have duded and.

405
00:22:11,350 --> 00:22:18,970
Then I will take a very well I, which is initialized to two and some, which is initially zero.

406
00:22:23,840 --> 00:22:26,780
And this little children, Bill I.

407
00:22:26,990 --> 00:22:29,570
Is less than equal to.

408
00:22:29,900 --> 00:22:32,420
And so if this condition is true.

409
00:22:33,860 --> 00:22:34,820
What do they do?

410
00:22:36,420 --> 00:22:42,080
Add to the current sum for the new value of some as it goes to all the value of them plus eight.

411
00:22:42,120 --> 00:22:43,220
So this is all value.

412
00:22:43,920 --> 00:22:45,300
And this is the new value of some.

413
00:22:46,610 --> 00:22:51,640
And then I am doing good, wonder if I buy it, or so I will say, blessed because we have to only consider

414
00:22:51,660 --> 00:22:52,510
it unanimous.

415
00:22:52,700 --> 00:22:54,390
And then I will check my condition again.

416
00:22:55,510 --> 00:22:58,610
If this condition is false, I will print.

417
00:23:00,090 --> 00:23:00,570
Some.

418
00:23:02,820 --> 00:23:05,130
And then I will add my program.

419
00:23:07,380 --> 00:23:07,590
OK.

420
00:23:07,760 --> 00:23:11,160
So let's see how this flowchart will work.

421
00:23:16,400 --> 00:23:25,430
Let's say, and it calls for a strike program I read and initially, I quote to some equals zero.

422
00:23:25,850 --> 00:23:28,910
So is do less than I guess to force their condition is true.

423
00:23:28,920 --> 00:23:29,630
You will come here.

424
00:23:31,310 --> 00:23:32,630
And it was a cut in some.

425
00:23:33,820 --> 00:23:36,750
So some IT quotes do.

426
00:23:37,300 --> 00:23:42,470
And then I have to go the value, if I buy do so, I become four.

427
00:23:43,180 --> 00:23:44,640
And then you will come here.

428
00:23:46,150 --> 00:23:51,180
So is for less dingoes to fall, so the condition is true, you will come here and I do the gotten in

429
00:23:51,180 --> 00:23:54,250
some sort of some way become four.

430
00:23:54,790 --> 00:23:58,860
And then in Gurinder earlier fibre to the new earlier fire is six.

431
00:23:59,230 --> 00:24:00,850
Then you will again check the condition.

432
00:24:01,270 --> 00:24:02,730
It takes less than a glitch to win.

433
00:24:02,950 --> 00:24:03,430
No.

434
00:24:03,880 --> 00:24:04,750
So you will come here.

435
00:24:04,780 --> 00:24:06,280
Sorry I did something wrong.

436
00:24:06,580 --> 00:24:07,780
It should be blessed also.

437
00:24:08,260 --> 00:24:10,860
So six here is this condition is false.

438
00:24:10,960 --> 00:24:15,490
You will come here, bring some to six will be printed and then you will end your program.

439
00:24:16,030 --> 00:24:16,870
And six is done.

440
00:24:16,870 --> 00:24:18,490
So for unequals for.

441
00:24:20,110 --> 00:24:23,110
OK, so let's say and equals five.

442
00:24:23,980 --> 00:24:26,180
So you start the program, do you then?

443
00:24:26,290 --> 00:24:28,110
Initially I will do some because it'll.

444
00:24:29,320 --> 00:24:30,550
Some equals zero.

445
00:24:31,030 --> 00:24:32,620
I equals two initially.

446
00:24:33,370 --> 00:24:36,010
Then your check is too less than it goes to five.

447
00:24:36,040 --> 00:24:37,030
So the condition is true.

448
00:24:37,170 --> 00:24:37,960
You will come here.

449
00:24:39,560 --> 00:24:47,720
Add to the current, some sort of sum equals oil value of some plus A, which is to OK.

450
00:24:48,440 --> 00:24:55,010
Now we have to and given the way I live, if I were to see the new value, if I is for Jack, the condition

451
00:24:55,010 --> 00:24:57,650
again is for less than it was two five.

452
00:24:57,800 --> 00:24:58,670
So the condition is true.

453
00:24:58,670 --> 00:24:59,710
You will again come here.

454
00:25:01,000 --> 00:25:05,930
So the new really awesome as it goes to all the value of some place A.

455
00:25:07,530 --> 00:25:08,470
That is six.

456
00:25:08,890 --> 00:25:13,000
Then you have to increment the value of five for the new value, if I will become six.

457
00:25:13,090 --> 00:25:14,620
And then you will check the condition again.

458
00:25:14,650 --> 00:25:17,920
So is six less than Noriko's to five.

459
00:25:17,950 --> 00:25:19,030
So the condition is false.

460
00:25:19,090 --> 00:25:19,840
You will come here.

461
00:25:20,140 --> 00:25:21,220
You will print some.

462
00:25:21,670 --> 00:25:25,000
So six will be printed and then you will end endure program.

463
00:25:25,480 --> 00:25:28,790
You can consider this problem a little bit tough for beginner.

464
00:25:29,710 --> 00:25:31,130
So let us revise what we have done.

465
00:25:39,390 --> 00:25:46,140
So the problem was given and we have to find the sum of even numbers from one to N, for example, and

466
00:25:46,140 --> 00:25:46,860
it was six.

467
00:25:47,100 --> 00:25:49,840
So the output should be two plus four plus six.

468
00:25:49,950 --> 00:25:55,470
At this point, if any of those five are butchered, we tubeless for those six as immediately Franklin's

469
00:25:55,470 --> 00:25:56,820
Truthout, which should be two.

470
00:25:57,330 --> 00:25:58,080
So what do I do?

471
00:25:58,410 --> 00:26:04,590
I will take a very delay and will initialize the variable with two, because two is the first even number

472
00:26:04,590 --> 00:26:09,660
from one to N, and then I will run the loop in the loop.

473
00:26:09,750 --> 00:26:16,830
I will be doing some work and this loop will run until I is less than or equal to doing so.

474
00:26:17,160 --> 00:26:22,980
Less than articles to an annual increment of value if I may do, because I have to only consider even

475
00:26:22,980 --> 00:26:23,350
number.

476
00:26:24,330 --> 00:26:26,340
And what is the Vogtle we're doing here?

477
00:26:27,420 --> 00:26:29,520
Simply, I will take a variable sum.

478
00:26:29,580 --> 00:26:32,520
So the new value of some will be the oil value of some.

479
00:26:33,660 --> 00:26:34,350
Bless a.

480
00:26:35,680 --> 00:26:38,410
And finally, my son will be storing my answer.

481
00:26:39,190 --> 00:26:41,230
And here you can see the diagram.

482
00:26:41,320 --> 00:26:43,250
OK, let's run another example, let's say.

483
00:26:43,320 --> 00:26:46,000
And it goes, do you start the program?

484
00:26:46,840 --> 00:26:52,000
Read and I quote, to sum it goes, it'll sum it close to zero.

485
00:26:52,420 --> 00:26:53,920
I equals to.

486
00:26:55,850 --> 00:27:01,550
Is to less than English to do for the condition is true, you will come here some equals, some blasé.

487
00:27:02,660 --> 00:27:04,460
Some equals some.

488
00:27:05,270 --> 00:27:07,760
Plus I this, too, okay?

489
00:27:08,110 --> 00:27:11,950
Incremental value, if I were to show the new value of ideas for.

490
00:27:12,320 --> 00:27:14,180
And then you will check the condition again.

491
00:27:14,990 --> 00:27:17,860
So is for less than articles to do.

492
00:27:17,920 --> 00:27:18,980
So the condition is false.

493
00:27:19,040 --> 00:27:19,710
You will come here.

494
00:27:19,760 --> 00:27:20,600
You will print some.

495
00:27:22,170 --> 00:27:24,460
And then you will learn to program for animals, too.

496
00:27:24,660 --> 00:27:27,540
My answer is to which is hundred percent correct.
