WEBVTT

00:00.900 --> 00:08.460
The next question is to write a function that returns this sum of multiples of either one of three or

00:08.460 --> 00:12.900
five between zero and the limited value which we will be providing.

00:13.860 --> 00:19.410
So, for example, if the limit is set to 20, then it should return the sum of numbers.

00:19.680 --> 00:26.130
Three, five, six, nine, 10, 12, 15, 18 and 20, which are multiples of three and five.

00:28.910 --> 00:33.890
So to solve this question, first of all, we will need to get the limited value.

00:34.520 --> 00:36.290
So let's get the limited funding first.

00:38.420 --> 00:45.170
We can simply get it where input, but I am taking it as a random value, let's say integral footprint.

00:48.740 --> 00:58.910
Next, we need to identify if a particular number is ranging in a way that it is a multiple of three

00:58.910 --> 00:59.330
or five.

00:59.360 --> 01:02.390
So how do we find out if a number is a multiple of three or five?

01:02.750 --> 01:10.880
So let's say we have the number X and we want to find out if it is a multiple of five, then we need

01:10.880 --> 01:12.170
to find out the remainder.

01:12.800 --> 01:19.220
So if it is divided by three and the remainder comes out to zero, then it is a multiple of three.

01:23.570 --> 01:26.510
Now, let's check this on a range of.

01:37.690 --> 01:38.200
Twenty

01:41.740 --> 01:42.790
and reflectance.

01:58.630 --> 02:08.530
So here you can see that these numbers, zero three six nine, 12, 15, 18 are divisible by three.

02:10.130 --> 02:13.340
Next, let's do it for five as.

02:14.140 --> 02:15.460
So same condition.

02:15.460 --> 02:20.320
If I got five in place of this, we get zero, five, 10, 15.

02:20.680 --> 02:26.090
So this particular condition decides if the number is divisible by five or three.

02:26.110 --> 02:29.800
So I can simply copy this book here.

02:30.880 --> 02:36.370
Change this to three and four, little or in between.

02:37.390 --> 02:39.920
So this will check for both three and five.

02:40.210 --> 02:41.170
Let's run this again.

02:41.860 --> 02:42.760
So we get this.

02:43.600 --> 02:51.310
Now, what we want to do is we want to get this some of these values so I can simply create a believable

02:51.310 --> 02:52.450
as say.

02:56.390 --> 03:04.820
Is that's the south, so we insulator to zero, and every time the condition is fulfilled, we'll say

03:04.820 --> 03:08.110
is is equal to S plus X.

03:08.510 --> 03:13.180
And finally, once everything is over, then sprint.

03:15.110 --> 03:15.330
Yes.

03:17.150 --> 03:19.820
So we get 78 as a result.

03:20.450 --> 03:27.770
Now, one more thing is that while I run this, I'm not getting 20 because it is skipping to indeed

03:27.770 --> 03:29.630
this counting from zero to 20.

03:30.020 --> 03:34.310
So instead of 20, we need to give it instead of 20.

03:34.430 --> 03:37.460
We need to give it and plus one.

03:39.860 --> 03:42.830
Now, you see 20s also being considered here.

03:45.020 --> 03:48.250
Now, this is a little longer in nature.

03:48.260 --> 03:50.830
We don't want to write too many lines of code.

03:50.840 --> 03:57.860
We can simplify this into a very simple, small and concise line of code so we can convert this in a

03:57.860 --> 03:58.190
way.

03:58.490 --> 04:03.110
So we want to find out some of.

04:05.560 --> 04:16.750
Some numbers which are ranging, let's create a list of her for X in range in plus one.

04:18.040 --> 04:22.280
We want to get X and we want to add them together.

04:22.300 --> 04:28.570
So let's get the value here by just giving 210, because now right now I'm adding everything.

04:28.570 --> 04:31.660
But we have not included this particular condition from here.

04:32.020 --> 04:37.360
So let's pick this condition and paste it here.

04:37.660 --> 04:45.370
So what we are seeing is for X in range and plus one that is numbers ranging from zero to 20.

04:45.740 --> 04:50.170
Check if the number is divisible by three or five.

04:50.500 --> 04:57.580
And if it is completely divisible and the remainder comes out to be zero, simply add all those numbers

04:57.580 --> 04:59.140
together and give me the result.

05:00.220 --> 05:01.120
And here we go.

05:02.080 --> 05:03.970
So this is how we create this.

05:04.450 --> 05:09.610
Now, the question was to create a function which would do this.

05:10.450 --> 05:13.090
So right now, we have created the logic for it.

05:13.120 --> 05:16.450
Now we need to create a function which will do this for us.

05:16.750 --> 05:24.010
So for writing a function, we can simply say there are function neame, let's say Adir.

05:25.300 --> 05:27.640
And it will take numbers.

05:27.880 --> 05:28.600
So see.

05:30.400 --> 05:31.540
And what is this num?

05:31.540 --> 05:32.830
This number will be in.

05:33.730 --> 05:35.110
So what should you do?

05:35.140 --> 05:42.520
It will simply don these values to us.

05:43.360 --> 05:47.680
And if you want to run this, we can simply see print

05:51.220 --> 05:55.890
ad and run added with any number.

05:55.900 --> 05:58.720
So let the number be wati.

06:01.360 --> 06:05.860
And here we have in.

06:05.860 --> 06:08.120
So let's num.

06:09.460 --> 06:10.540
And here we get the result.

06:11.350 --> 06:17.740
So this is how you need to strategize your solution, how you need to write your code.

06:18.010 --> 06:25.300
So first you can write the code in a very simple manner and write your lubes clearly so that your logic

06:25.300 --> 06:25.960
is correct.

06:26.290 --> 06:31.450
Then you can convert it into a list comprehension or any other technique if possible.

06:31.750 --> 06:38.350
And then you added to the definition of the function so that your solution is clear and cutting.
