| | |
Perfect number - python
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 35
Reputation:
Solved Threads: 1
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.
I need help working out with line 1, how it says , how do you write it so it goes up to n so I can divide it by 2?
HELP PLEASE!
Thanks
I've worked out some code, but I'm stuck.
Python Syntax (Toggle Plain Text)
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 ton/2HELP PLEASE!
Thanks
you use a range.
python Syntax (Toggle Plain Text)
for variable in range(n/2): #do stuff
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
![]() |
Similar Threads
- Help (Python)
Other Threads in the Python Forum
- Previous Thread: Python challenge help
- Next Thread: passing int as 64 bit integer to COM
| Thread Tools | Search this Thread |
Tag cloud for Python
ansi assignment avogadro backend beginner binary bluetooth character cmd code customdialog data decimals dictionary drive dynamic error examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java leftmouse line linux list lists logging loop module mouse newb number numbers output parsing path pointer port prime program programming progressbar projects push py2exe pygame pyqt python random recursion recursive refresh schedule screensaverloopinactive script scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib





