login
Sum of distinct decimal digits appearing in n.
7

%I #19 Sep 21 2022 12:37:51

%S 0,1,2,3,4,5,6,7,8,9,1,1,3,4,5,6,7,8,9,10,2,3,2,5,6,7,8,9,10,11,3,4,5,

%T 3,7,8,9,10,11,12,4,5,6,7,4,9,10,11,12,13,5,6,7,8,9,5,11,12,13,14,6,7,

%U 8,9,10,11,6,13,14,15,7,8,9,10,11,12,13,7,15,16,8,9,10,11,12,13,14,15,8,17,9,10,11,12,13,14,15,16,17,9,1

%N Sum of distinct decimal digits appearing in n.

%C a(n) <= 45 = 1+2+3+4+5+6+7+8+9; A227378(n) = smallest number m such that a(m) = n, 0 <= n <= 45. - _Reinhard Zumkeller_, Jul 09 2013

%H Reinhard Zumkeller, <a href="/A217928/b217928.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>

%F a(n) = A007953(A180410(n)). - _Michel Marcus_, Sep 21 2022

%p a:= n-> add(i, i={convert(n, base, 10)[]}):

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Sep 21 2022

%o (PARI) { a(n) = local( d = vecsort( eval(Vec(Str(n))),,8) ); sum(i=1,#d,d[i]) }

%o (PARI) a(n) = vecsum(Set(digits(n))); \\ _Michel Marcus_, Sep 13 2022

%o (Haskell)

%o import Data.List (nub)

%o a217928 = sum . nub . map (read . return) . show :: Integer -> Integer

%o -- _Reinhard Zumkeller_, Jul 09 2013

%o (Python)

%o def a(n): return sum(map(int, set(str(n))))

%o print([a(n) for n in range(101)]) # _Michael S. Branicky_, Sep 13 2022

%Y Cf. A007953, A180410.

%K base,easy,nonn

%O 0,3

%A _Max Alekseyev_, Oct 15 2012