login
A360391
a(n) is the number of distinct sums of nonempty subsets of the digits of n.
2
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,11
COMMENTS
1 <= a(n) <= 2^(1 + floor(log_10(n))) - 1.
LINKS
EXAMPLE
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.
MATHEMATICA
a[n_] := Length[Union[Total /@ Select[Subsets[IntegerDigits[n]], # != {} &]]]; Array[a, 100, 0] (* Amiram Eldar, Feb 06 2023 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Ctibor O. Zizka, Feb 06 2023
STATUS
approved