Hi guys, I'm currently working on a program to return whether an inputted number is perfect or not. I've found that the formula for the perfect number is If 2n-1 is prime then 2(n-1)(2n-1) is perfect.
I've worked out some code, but I'm stuck.

Def listfactors(n):
For 1=2 to n/2  sum(list)
      If 2 = int(2/20):
         List.append(i)

I need help working out with line 1, how it says

1=2 [U]to[/U]n/2

, how do you write it so it goes up to n so I can divide it by 2?
HELP PLEASE!
Thanks :)

you use a range.

for variable in range(n/2):
    #do stuff
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.