A360391 a(n) is the number of distinct sums of nonempty subsets of the digits of n.
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
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 0..10000
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
Comments