0

I'm trying to make a perfect numbers script but having almost no success...

Perfect numbers are those whose factors add up to twice the number itself... factors don't have to be prime...

So like the first four are 6, 28, 496, 8128...

28: 1,2,4,7,14,28

1 + 2 + 4 + 7 + 14 + 28 = 56

56 = 28*2

I've made a prime numbers script, and a factorization script, but this one I just can't get right...

Here's one of the simpler ways i was trying to do it:

```
print ("Perfect Numbers")
a = 0
b = []
while True:
for n in range(a+1):
if n is not 0:
if a % n is 0:
b.append(n)
m = sum(b)
if m is 2*a:
print(a)
a += 1
```

I've tried making lots of variations, but all the times it gives me a couple wrong numbers, i.e. 2 or 6,8 and/or just freezes... if only it could find me the first few perfect numbers...