A385158 Numbers k such that the sum of the digits of k is a number that appears as a substring of k, and every nonzero digit of k appears in that sum.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 199, 200, 300, 400, 500, 600, 700, 800, 900, 919, 1000, 1188, 1818, 1881, 1909, 1990, 2000, 2999, 3000, 4000, 5000, 6000, 7000, 8000, 8118, 8181, 9000, 9019, 9190, 9299, 9929, 10000
Offset: 1
Examples
1818 is in the sequence because 1 + 8 + 1 + 8 = 18, and 18 appears within the number. Also, all nonzero digits (1 and 8) are found in the digit sum (18).
Crossrefs
Programs
-
Maple
filter:= proc(k) local L,s,S,nL,nS,i; L:= convert(k,base,10); nL:= nops(L); s:= convert(L,`+`); S:= convert(s,base,10); nS:= nops(S); (convert(L,set) minus {0} = convert(S,set) minus {0}) and member(S, [seq(L[i..i+nS-1],i=1..nL-nS+1)]) end proc: select(filter, [$1..10000]); # Robert Israel, Jul 23 2025
-
Mathematica
isok[n_] := Module[{digits, sum, sumStr}, digits = IntegerDigits[n]; sum = Total[digits]; sumStr = ToString[sum]; StringContainsQ[ToString[n], sumStr] && AllTrue[DeleteCases[digits, 0], DigitCount[sum, 10, #] > 0 &] ]; Select[Range[9999], isok]
-
Python
def ok(n): digits = str(n) digit_sum_str = str(sum(map(int, digits))) return digit_sum_str in digits and all(d in digit_sum_str for d in set(digits) - {'0'}) print([k for k in range(1, 10001) if ok(k)])