00:01
For this one, we're looking for perfect numbers.
00:04
And so when i get my perfect numbers, i'm going to store them in a string.
00:10
And actually, i'm not going to store them in a string.
00:12
I'm going to store them in a list.
00:13
And so i'm going to make my list with all of my perfect numbers.
00:18
We're told that we have four of them between or less than 10 ,000.
00:24
So there's probably nice ways to do optimization to make this go quicker.
00:28
I'm going to do some serious brute force in this program.
00:35
I'm going to test every number from 1 to 10 ,000, and so i'm going to type in 10 ,0001 for my range.
00:45
And so for each one of those, i'm going to look for the, to see if any of those are perfect numbers.
00:54
I'm going to say that my number is equal to my value, value and i don't need to do that.
01:05
When i originally wrote that, i was thinking we were going to be factoring the number and we're doing something slightly different.
01:12
I'm going to use the word divisors because i want to find all the number.
01:19
When i've like 14, i want to find all the numbers that equally divide into 14, which be one, two, seven, and 14.
01:29
So divisors, i'm going to build a list.
01:31
Nope, i'm going to build a list.
01:33
Of my divisors and then i'm going to start off saying for factor could call that divisor in range one to value and actually my example earlier i would not want to use 14 as one of the divisors okay so we want to test to see if the factor is evenly divisible by or evenly divides the numbers i'm going to say the number when i divide the number by factor, if i get a zero, i know that the number is an integer divisor, and then i'm gonna say divisors dot append, and i'm gonna add the number.
02:43
Actually, it's called a factor.
02:44
I'm gonna add the factor to the list.
02:49
When i get done with that, so for each of those numbers, when i get my list of divisors, i'm going to get my, i'm going to create a variable called factor sum.
03:04
I'm going to call that equal to zero and four.
03:09
You could call it divisor.
03:11
I'm just going to call it item.
03:12
For item in divisors.
03:17
Divisors.
03:19
So i'm going to go through each of the divisors.
03:21
So one, two, and seven for 14.
03:26
And i'm going to increment factor sum.
03:33
By the value of that divisor value...