Please could you help correct this code! It's for finding all perfect numbers below the set limit of 10,000, I've used comments to explain what I'm doing. Thanks!
#Stores list of factors and first perfect number
facs = []
x = 1
#Defines function for finding factors
def findfactors(num):
#Creates for loop to find all factors of num
for i in range(1, num + 1):
if num % i == 0:
#Stores factor in facs
facs.append(i)
#Activates loop
while x < 10000:
#Finds factors of x and appends them to list
findfactors(x)
#Finds sum of list
facsum = sum(facs)
#Makes decision based on sum of factors and original number
if facsum == x:
#Ouputs and increases x
print(x)
x += 1
else:
#Increases x
x += 1