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.

A342048 Numbers for which the sum of digits equals the product of nonzero digits.

This page as a plain text file.
%I A342048 #14 Feb 28 2021 18:52:00
%S A342048 1,2,3,4,5,6,7,8,9,10,20,22,30,40,50,60,70,80,90,100,123,132,200,202,
%T A342048 213,220,231,300,312,321,400,500,600,700,800,900,1000,1023,1032,1124,
%U A342048 1142,1203,1214,1230,1241,1302,1320,1412,1421,2000,2002,2013,2020,2031,2103,2114,2130,2141,2200
%N A342048 Numbers for which the sum of digits equals the product of nonzero digits.
%H A342048 Robert Israel, <a href="/A342048/b342048.txt">Table of n, a(n) for n = 1..10000</a>
%e A342048 2103 is in the sequence because 2 + 1 + 0 + 3 = 2 * 1 * 3 = 6.
%p A342048 q:= n-> (l-> is(add(i, i=l)=mul(i, i=l)))(
%p A342048         subs(0=[][], convert(n, base, 10))):
%p A342048 select(q, [$0..3300])[];  # _Alois P. Heinz_, Feb 26 2021
%p A342048 # alternative
%p A342048 G:= proc(d,dmax,s,p) option remember; local i;
%p A342048    if s + dmax*d < p or s > dmax^d*p then return [] fi;
%p A342048    if d = 0 then return [[]] fi;
%p A342048    [seq(op(map(t -> [i,op(t)], procname(d-1,i,s+i,p*i))),i=1..dmax)]
%p A342048 end proc:
%p A342048 f:= proc(d) local R,k,i;
%p A342048   R:= [seq(op(map(t -> [0$k,op(t)], G(d-k,9,0,1))),k=0..d-1)];
%p A342048   R:= map(op@combinat:-permute,R);
%p A342048   sort(map(t -> add(t[i]*10^(i-1),i=1..d),R))
%p A342048 end proc:
%p A342048 f(4); # _Robert Israel_, Feb 28 2021
%t A342048 Select[Range[2200], Plus @@ IntegerDigits[#] == Times @@ DeleteCases[IntegerDigits[#], 0] &]
%o A342048 (Python)
%o A342048 from math import prod
%o A342048 def ok(n):
%o A342048   digs = list(map(int, str(n)))
%o A342048   return sum(digs) == prod([d for d in digs if d != 0])
%o A342048 def aupto(lim): return [m for m in range(1, lim+1) if ok(m)]
%o A342048 print(aupto(2200)) # _Michael S. Branicky_, Feb 26 2021
%o A342048 (PARI) isok(k) = my(d=select(x->(x>0), digits(k))); vecprod(d) == vecsum(d); \\ _Michel Marcus_, Feb 26 2021
%Y A342048 Cf. A007953, A034710, A051801.
%K A342048 nonn,base
%O A342048 1,2
%A A342048 _Ilya Gutkovskiy_, Feb 26 2021