Perfect numbers: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: replaced reduce(add) with sum)
Line 2,140: Line 2,140:
Functional style:
Functional style:
<lang python>perf = lambda n: n == sum(i for i in xrange(1, n) if n % i == 0)</lang>
<lang python>perf = lambda n: n == sum(i for i in xrange(1, n) if n % i == 0)</lang>



Or, a little faster (by restricting the search space):
Or, a little faster (by restricting the search space):
Line 2,170: Line 2,171:




# GENERIC-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
# GENERIC --------------------------------


# concatMap::(a - > [b]) - > [a] - > [b]
# concatMap::(a - > [b]) - > [a] - > [b]