Perfect numbers: Difference between revisions
m
→{{header|Python}}: Updated a primitive ( concatMap )
m (→{{header|Python}}: Updated a primitive ( concatMap )) |
|||
Line 2,325:
Or, a little faster (by restricting the search space):
<lang python>from
from math import (sqrt)
Line 2,345 ⟶ 2,346:
lows + concatMap(
lambda x: (
lambda y=(n / x): [y] if x != y else []
)()
)(lows)
Line 2,358 ⟶ 2,357:
# concatMap :: (a -> [b]) -> [a] -> [b]
def concatMap(f):
Line 2,371 ⟶ 2,369:
if __name__ == '__main__':
main()</lang>
{{Out}}
<pre>[6, 28, 496, 8128]</pre>
|