cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A360391 a(n) is the number of distinct sums of nonempty subsets of the digits of n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2
Offset: 0

Views

Author

Ctibor O. Zizka, Feb 06 2023

Keywords

Comments

1 <= a(n) <= 2^(1 + floor(log_10(n))) - 1.

Examples

			k = 10: sums of digits are {0, 1, 0 + 1}, distinct sums of digits are {0, 1}, thus a(10) = 2.
k = 11: sums of digits are {1, 1 + 1}, distinct sums of digits are {1, 2}, thus a(11) = 2.
k = 12: sums of digits are {1, 2, 1 + 2}, distinct sums of digits are {1, 2, 3}, thus a(12) = 3.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Length[Union[Total /@ Select[Subsets[IntegerDigits[n]], # != {} &]]]; Array[a, 100, 0] (* Amiram Eldar, Feb 06 2023 *)
  • Python
    from itertools import combinations as C
    def a(n):
        v = list(map(int, str(n)))
        return len(set(sum(c) for r in range(1, len(v)+1) for c in C(v, r)))
    print([a(n) for n in range(89)]) # Michael S. Branicky, Feb 19 2023