Perfect numbers: Difference between revisions
Content deleted Content added
→Functional Python (faster version): A simplification, with one less import. |
→Functional Python: Simplifying time compression. Updated relative time comment in preamble. |
||
Line 2,330:
Or, over
<lang python>'''Perfect numbers'''
Line 2,340:
def perfect(n):
'''Is n the sum of its proper divisors other than 1 ?'''
root = sqrt(n)
lows =
return 1 < n and (
n == sum(lows + [n / x for x in lows if root != x]) / 2
Line 2,356 ⟶ 2,351:
def main():
'''Test'''
x for x in enumFromTo(1)(10000) if perfect
])▼
▲ )
|