%I #24 Sep 08 2022 08:46:10
%S 0,1,2,3,4,5,6,7,8,9,199,919,991,1188,1818,1881,2999,8118,8181,8811,
%T 9299,9929,9992,11177,11444,11717,11771,13333,14144,14414,14441,17117,
%U 17171,17711,22888,26666,28288,28828,28882,31333,33133,33313,33331,39999,41144
%N Numbers n for which the digital sum of n contains the same distinct digits as n itself.
%H Chai Wah Wu, <a href="/A249515/b249515.txt">Table of n, a(n) for n = 1..4477</a>
%e 199 is in the sequence since 1 + 9 + 9 = 19.
%t Select[Range[1000], Union[IntegerDigits[#]] == Union[Plus@@IntegerDigits[#]] &] (* _Alonso del Arte_, Nov 02 2014 *)
%o (Magma) [n: n in [0..1000000] | Set(Intseq(n)) eq Set(Intseq(&+Intseq(n)))]
%o (PARI) for(n=0, 5*10^4, if(vecsort(digits(n),,8) ==vecsort(digits(sumdigits(n)),,8), print1(n,", "))) \\ _Derek Orr_, Nov 02 2014
%o (Python)
%o from itertools import product
%o A249515_list = [0]
%o for g in range(1,12):
%o ....xp, ylist = [], []
%o ....for i in range(9*g,-1,-1):
%o ........x = set(str(i))
%o ........if not x in xp:
%o ............xv = [int(d) for d in x]
%o ............imin = int(''.join(sorted(str(i))))
%o ............if max(xv)*(g-len(x)) >= imin-sum(xv) and i-sum(xv) >= min(xv)*(g-len(x)):
%o ................xp.append(x)
%o ................for y in product(x,repeat=g):
%o ....................if y[0] != '0' and set(y) == x and set(str(sum([int(d) for d in y]))) == x:
%o ........................ylist.append(int(''.join(y)))
%o ....A249515_list.extend(sorted(ylist)) # _Chai Wah Wu_, Nov 15 2014
%Y Cf. A007953, A249516, A249517.
%K nonn,base,easy
%O 1,3
%A _Jaroslav Krizek_, Oct 31 2014