I am having trouble writing a program that lists the perfect numbers less than 10,000 in JES. This is what I have so far. Can someone help me?

def perfect():
    print "Perfect Numbers"
    count = 0
    number = 4
    while count < 10000:
        if sumsDivs(number):
            count = count + 1
            print count, "\t", number
    number = number + 1


def sumsDivs(n):  
    for trialDiv in range(0,10000):
        if n % trialDiv == 0:
            break
    return sum

You should be getting an error in the sumsDivs() function because you return the variable "sum" which is never declared or defined, and is a reserved word so should not be used as a variable name. Also, you call sumsDivs(number), but never change the value of number within the while() loop, so you are always testing the same number. You should explain what a perfect number is, for anyone reading this who doesn't know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.