Harshad or Niven series: Difference between revisions

m
→‎Python: Functional: Pruned out one import.
m (→‎Python: Functional: Updated primitives)
m (→‎Python: Functional: Pruned out one import.)
Line 3,217:
>>> </lang>
 
And we cancould also sum digits more directly (without string coercion) while still preserving functional composition:
 
{{Works with|Python|3.7}}
<lang python>'''Harshad or Niven series'''
 
from itertools import chain, count, dropwhile, islice
 
 
Line 3,228:
def harshads():
'''Harshad series'''
defreturn go(x):
return [x] iffor 0 == (x %in digitSumcount(x1)) else []
if 0 == x % digitSum(x)
return chain.from_iterable(
map(go, count(1))
)
 
Line 3,333 ⟶ 3,332:
# MAIN ---
if __name__ == '__main__':
main()</lang>
</lang>
{{Out}}
<pre>Harshad or Niven series:
9,659

edits