ok ... first i had to make a function that tells you if the number you choose is a magic number or not ....(perfect number) ... i figured that out

now i have to make a function that prints the magic number ...
The second function, called print_magic, has a single parameter Num. It prints all magic numbers between 2 and Num ..... im haven trouble with telling python to print the numbers between 2 and Num

if i was to call it ... it looks like this
>>>print_magic(100)
6, 28

im jus learning how to use the accumulator but i still need sum work lol ...can sum one help me?

def magic(N):
    acc = 0
    for i in range(1, N):
        if (N % i == 0):
            factor = i
            acc += factor
    if (acc == N):
        print ("True")
    else:
        print ("False")



def print_magic(Num):
    acc = 0
    for i in range(Num):
        factor = i
        acc = acc + Num % i == 0
        return acc
rsdodla commented: check sequences +0

im jus learning how to use the accumulator but i still need sum work lol ...can sum one help me?

First, not too many people are going to take the trouble to translate kiddie-speak into English.

Second, the customary way is to send one number to magic() and have it return True or False. You can then use a loop, or iterate through a custom list, to test more than one number.

First, not too many people are going to take the trouble to translate kiddie-speak into English.

Second, the customary way is to send one number to magic() and have it return True or False. You can then use a loop, or iterate through a custom list, to test more than one number.

"kiddie-speak English"
First of all .... if you felt that way u didnt have to reply. that comment was unnecessary ... i type all damn day so thats why i short everything ... this is programming Not english class

thanks for the tip

I would approach it this way ...

def is_magic(n):
    """check if n is a perfect (magic) number"""
    acc = 0
    for i in range(1, n):
        if (n % i == 0):
            factor = i       # these 2 lines could be acc += i
            acc += factor
    if (acc == n):
        return True
    else:
        return False


def print_magic(limit):
    """print all the perfect numbers up to limit"""
    for i in range(1, limit):
        if is_magic(i):
            print( i )


# test function ismagic
n = 28
print is_magic(n)

# test function print_magic
# this is a brute force approach and takes
# quite a bit of time with larger limits
# (wait till you are done)
print( "wait ..." )
print_magic(10000)
print( "... done!" )
commented: Always Helpfull :-) +1

thanks vegaseat .. you are always helpful and polite

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.