cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A385158 #34 Jul 23 2025 14:43:33
%S A385158 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,199,200,300,400,500,
%T A385158 600,700,800,900,919,1000,1188,1818,1881,1909,1990,2000,2999,3000,
%U A385158 4000,5000,6000,7000,8000,8118,8181,9000,9019,9190,9299,9929,10000
%N 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.
%e A385158 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).
%p A385158 filter:= proc(k) local L,s,S,nL,nS,i;
%p A385158   L:= convert(k,base,10);
%p A385158   nL:= nops(L);
%p A385158   s:= convert(L,`+`);
%p A385158   S:= convert(s,base,10);
%p A385158   nS:= nops(S);
%p A385158   (convert(L,set) minus {0} = convert(S,set) minus {0}) and member(S, [seq(L[i..i+nS-1],i=1..nL-nS+1)])
%p A385158 end proc:
%p A385158 select(filter, [$1..10000]); # _Robert Israel_, Jul 23 2025
%t A385158 isok[n_] := Module[{digits, sum, sumStr},
%t A385158   digits = IntegerDigits[n];
%t A385158   sum = Total[digits];
%t A385158   sumStr = ToString[sum];
%t A385158   StringContainsQ[ToString[n], sumStr] &&
%t A385158     AllTrue[DeleteCases[digits, 0],
%t A385158       DigitCount[sum, 10, #] > 0 &]
%t A385158 ];
%t A385158 Select[Range[9999], isok]
%o A385158 (Python)
%o A385158 def ok(n):
%o A385158     digits = str(n)
%o A385158     digit_sum_str = str(sum(map(int, digits)))
%o A385158     return digit_sum_str in digits and all(d in digit_sum_str for d in set(digits) - {'0'})
%o A385158 print([k for k in range(1, 10001) if ok(k)])
%Y A385158 Cf. A052018, A007953, A031286 (numbers containing a given substring), A070939 (numbers equal to the sum of their digits concatenated), A061209 (numbers containing their digit sum).
%K A385158 nonn,base
%O A385158 1,2
%A A385158 _Rivka Maryles_, Jun 19 2025