Humble numbers: Difference between revisions
→{{header|Python}}: Defined humbles in terms of yield and set, rather than filter
(→{{header|Python}}: Defined humbles in terms of yield and set, rather than filter) |
|||
Line 1,755:
<lang python>'''Humble numbers'''
from itertools import
from functools import reduce
Line 1,765 ⟶ 1,764:
OEIS A002473
'''
return all(8 > x for x in primeFactors(x))▼
Line 1,785 ⟶ 1,787:
print('\nCounts of Humble numbers with n digits:\n')
for tpl in take(
(k, len(list(g))) for k, g in
groupby
):
print(tpl)
Line 1,804 ⟶ 1,806:
range(0, len(xs), n), []
) if 0 < n else []
'''▼
▲ def p(qr):
Line 1,849 ⟶ 1,814:
or xs itself if n > length xs.
'''
return lambda xs:
list(islice(xs, n))
▲ v = x
▲ while not p(v):
▲ v = f(v)
Line 1,883 ⟶ 1,837:
(3, 95)
(4, 197)
(5, 356)
(6, 579)
(7, 882)
(8, 1272)
(9, 1767)
(10, 2381)</pre>
=={{header|Racket}}==
|