Anonymous user
Practical numbers: Difference between revisions
→Composition of pure functions: Add Python types. Remove wrong and misleading Haskell type-comments.
mNo edit summary |
(→Composition of pure functions: Add Python types. Remove wrong and misleading Haskell type-comments.) |
||
Line 186:
from operator import mul
from functools import reduce
from typing import Any, List, Callable
'''True if n is a Practical number
(a member of OEIS A005153)
Line 200:
'''True if any subset of xs sums to n.
'''
Line 223 ⟶ 222:
# ------------------------- TEST -------------------------
'''Practical numbers in the range [1..333],
and the OEIS A005153 membership of 666.
Line 248 ⟶ 246:
# ----------------------- GENERIC ------------------------
'''A series of lists of length n, subdividing the
contents of xs. Where the length of xs is not evenly
Line 261 ⟶ 258:
'''A list of the prime factors of n.
'''
Line 287 ⟶ 283:
'''The ordered divisors of n, excluding n itself.
'''
Line 303 ⟶ 298:
'''Transposed matrix'''
def go(xss):
Line 319 ⟶ 313:
'''The result of repeatedly applying f until p holds.
The initial seed value is x.
Line 336 ⟶ 329:
# ---------------------- FORMATTING ----------------------
'''Tabulation with right-aligned cells'''
columnWidths = [
Line 356 ⟶ 348:
if __name__ == '__main__':
main()</lang>
{{Out}}
<pre>77 OEIS A005153 numbers in [1..333]
|