WEBVTT

00:01.110 --> 00:03.060
Let's solve the next item.

00:03.390 --> 00:10.830
So the problem here is greater function for food that determines if barometer number is a perfect number.

00:10.830 --> 00:15.300
So it needs a number which needs to be provided.

00:15.750 --> 00:20.550
And this function should tell us if the number is specific number.

00:20.610 --> 00:22.170
Now, what is a positive number?

00:22.530 --> 00:29.550
A ballpark number is if it is factors, including one, but not the number itself.

00:29.850 --> 00:32.460
Some Stoody number itself.

00:32.490 --> 00:34.290
So, for example, we have number six.

00:34.500 --> 00:37.680
So the factors of six would be one, two and three.

00:38.490 --> 00:41.970
And when we add one, two and three, it gives six as a result.

00:42.240 --> 00:43.410
So it is a perfect number.

00:44.550 --> 00:49.620
So we need to find a particular number if it is perfect or not.

00:51.030 --> 00:51.360
Right.

00:51.630 --> 00:54.930
So try this at your end.

00:55.590 --> 00:57.830
Please note the conditions which are given.

00:57.840 --> 01:04.590
So we need to run this for a range of numbers between one and thousand and return whatever number is

01:04.590 --> 01:05.070
perfect.

01:05.610 --> 01:05.940
OK.

01:06.120 --> 01:07.890
So you can possibly do.

01:07.890 --> 01:13.200
And I told them this question and you can look at the solution in case you want.

01:13.830 --> 01:15.180
So you can post a video now.

01:22.900 --> 01:28.540
OK, so let's solve the solution, Smiths solve this problem now.

01:30.850 --> 01:34.480
So we will not create the function first, we will try to solve.

01:34.510 --> 01:41.110
Find the logic first, and then we will convert this logic into a solution, into dual function.

01:42.460 --> 01:45.580
So let's create a sum.

01:45.580 --> 01:51.700
So let's first of all, we need to find out the numbers or let's consider a number, let's say in.

01:52.950 --> 01:55.180
And this end is equal to six.

01:55.450 --> 01:55.750
OK.

01:56.230 --> 01:57.910
Now let's create some.

01:58.300 --> 02:00.520
And assign this on as zero.

02:01.930 --> 02:10.750
Now for number in the range, whatever we are providing for, let's say, four numbers for whatever

02:10.750 --> 02:13.390
number there to number six, we are trying to solve this.

02:13.630 --> 02:14.830
So if in.

02:26.660 --> 02:29.580
Let's see divisible by any numbers.

02:29.930 --> 02:39.500
So let's try it four of my double numbers or for I in range.

02:41.690 --> 02:46.290
So the number factor can not be something which is zero.

02:46.310 --> 02:48.560
So the fact that has to be greater than zero.

02:48.860 --> 02:56.630
So we are seeing for a number from one to, let's say, number in total, that particular in for any

02:56.630 --> 02:56.990
number.

02:56.990 --> 02:58.970
We are checking the number itself.

02:59.360 --> 03:01.790
So we are checking from one to the number two.

03:02.330 --> 03:11.660
And because we will not consider six as the factors, we can go up in the range in and we need to check

03:12.290 --> 03:17.390
if the number is completely divisible by this factor or not.

03:17.810 --> 03:19.220
So we are saying if

03:22.670 --> 03:32.240
I is equal to zero, then let's simply put it this way.

03:33.380 --> 03:33.710
OK.

03:33.890 --> 03:35.450
So let's do this for now.

03:36.110 --> 03:37.340
So we are saying.

03:37.790 --> 03:41.660
So what it does is it checks for all the numbers from one to end.

03:42.170 --> 03:47.310
And whatever number is completely divisible by this number.

03:47.330 --> 03:51.250
So basically, all the factors it is giving out as a result.

03:51.290 --> 03:52.820
So it is printing all the factors.

03:53.120 --> 03:57.440
So let's say in sort of six, we had two forty eight.

03:58.130 --> 04:00.670
Then it will give Wollard all of its factors.

04:00.680 --> 04:04.640
If we had, let's say, seventy six, it will give all of its factors.

04:04.880 --> 04:05.990
So it goes like that.

04:07.400 --> 04:09.560
So this is what we are doing now.

04:09.620 --> 04:11.400
After this, we are seeing.

04:13.250 --> 04:15.560
So it is doing this one particular number.

04:15.890 --> 04:19.670
And then we are saying if the sum

04:22.760 --> 04:25.640
is equal to the number itself.

04:26.750 --> 04:27.080
OK.

04:27.320 --> 04:33.910
So it is checking for the entire range for this number.

04:33.920 --> 04:36.460
And so once it does it, it will.

04:36.470 --> 04:39.710
And the numbers would need to sum the numbers also.

04:39.980 --> 04:45.410
So we are seeing some physical do some plus

04:48.140 --> 04:51.110
I instead of some, let's call it.

04:54.510 --> 04:54.880
Yes.

04:55.590 --> 04:59.190
So that it does not override the actual stomach function.

04:59.730 --> 05:00.660
So we'll see.

05:01.320 --> 05:01.640
Here.

05:03.810 --> 05:10.950
And if it is equal to N, then we us we will return to.

05:14.130 --> 05:19.560
If not, then, yes, we will.

05:24.220 --> 05:25.050
The don

05:27.690 --> 05:31.800
was not the source for a particular number.

05:32.100 --> 05:37.410
Now we want to do this for a large list of numbers.

05:37.410 --> 05:39.450
We want to do it for multiple numbers.

05:39.870 --> 05:40.200
Right.

05:40.500 --> 05:44.070
So this will be done for a particular number.

05:44.070 --> 05:47.790
Now, I want to do this for multiple numbers, so I need to create a function for it.

05:48.150 --> 05:51.810
So how do I convert this into a function for converting this into a function?

05:52.200 --> 05:58.710
I can simply do what this perfect.

06:00.930 --> 06:09.150
And it will take and as an input and it will do all these steps for us.

06:10.260 --> 06:18.780
You can see I simply did a single tab which shifted all the line of code by one tab.

06:19.080 --> 06:22.020
So I don't need to keep pressing tab.

06:22.020 --> 06:27.240
Every time we want to move line, I can simply select everything and just do a single tab, push up

06:27.450 --> 06:27.870
everything.

06:30.030 --> 06:33.510
Now, once I'm done with this, I can run this piece of code.

06:34.440 --> 06:37.340
So let's say I want to run this for a large number.

06:37.350 --> 06:40.620
I want to run this for, let's say, 50 numbers, a thousand numbers.

06:40.920 --> 06:46.770
I can simply say for an in range.

06:49.050 --> 06:49.650
Thousand.

06:52.620 --> 06:54.600
Now, I don't want to run it for zero.

06:54.600 --> 06:56.610
So I can simply say start from one.

06:56.970 --> 07:01.520
And I want to consider a thousand here because I want to rantel thousand.

07:01.530 --> 07:07.180
So I need to give one thousand one, because then only it will run from one to one thousand.

07:07.230 --> 07:09.420
If I give one no extra, I don't need to do it.

07:09.930 --> 07:13.080
And after that, I want to run this function again and again.

07:13.440 --> 07:18.720
So I will see if I will run this function.

07:18.820 --> 07:24.800
I say I'll run both fake and inside this I will pass.

07:24.810 --> 07:26.880
And so it will run this.

07:27.090 --> 07:33.360
And every time this returns true because I have set fatal condition that it should return.

07:33.360 --> 07:33.690
True.

07:34.110 --> 07:39.960
If the number is perfect, that is, if the storm is equal to the number itself, then it will return

07:39.960 --> 07:40.080
it.

07:40.080 --> 07:43.830
So if it is returning true, then this is a condition itself.

07:43.830 --> 07:44.940
So I can simply say here.

07:45.600 --> 07:48.540
Well, if they thing, then it should bring

07:51.780 --> 07:52.320
into me.

07:58.380 --> 07:59.430
Or I can give

08:02.700 --> 08:06.840
I can simply give I also here, I can run it anyway.

08:06.870 --> 08:08.100
It is completely up to you.

08:08.760 --> 08:16.890
So you can see from one to 1000, 628 and four ninety six had the numbers, which are think in nature.

08:18.300 --> 08:20.370
We have made slight changes.

08:20.610 --> 08:28.640
It was like this, but it needs to be like this because we need to let it run for a while.

08:28.650 --> 08:34.410
We need to let it run for all the numbers from one to the number itself.

08:34.420 --> 08:41.940
And once these factors have been gone through and the sun miscalculated completely, then only the sun

08:41.960 --> 08:42.750
needs to be checked.
