Zumkeller numbers: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
→‎{{header|Python}}: Added a functionally composed variant, using only standard libraries.
Hout (talk | contribs)
Line 2,539: Line 2,539:
if even(m):
if even(m):
half = m // 2
half = m // 2
return True if half in ds else (
return half in ds or (
all(map(lambda x: half >= x, ds)) and (
all(map(lambda x: half >= x, ds)) and (
summable(half)(ds)
summable(half)(ds)
Line 2,554: Line 2,554:
'''
'''
def go(y, ys):
def go(y, ys):
if y and ys:
if ys:
if y in ys:
if y in ys:
return True
return True
Line 2,561: Line 2,561:
return (0 < d and go(d, ys[1:])) or go(y, ys[1:])
return (0 < d and go(d, ys[1:])) or go(y, ys[1:])
else:
else:
return 0 == y
return False
return lambda xs: go(x, xs)
return lambda xs: go(x, xs)


Line 2,717: Line 2,717:
# MAIN ---
# MAIN ---
if __name__ == '__main__':
if __name__ == '__main__':
main()
main()</lang>
</lang>
{{Out}}
{{Out}}
<pre>First 220 Zumkeller numbers:
<pre>First 220 Zumkeller numbers: