A230103 Number of m such that m + (product of digits of m) equals n.
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 2, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 3, 0, 0, 0, 1, 1, 1, 0, 1, 0, 2, 0, 2, 0, 0, 1, 1, 1, 1, 0, 2, 0, 0, 0, 2, 1, 0, 0, 1, 0, 3, 1, 0, 0, 0, 1, 2, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 2, 0, 2, 1, 3
Offset: 0
Links
Programs
-
Maple
# Maple code for A230099, A230103, A230104, A230105 with(LinearAlgebra): read transforms; # to get digprod M:=1000; lis1:=Array(0..M); lis2:=Array(0..M); ctmax:=4; for i from 0 to ctmax do ct[i]:=Array(0..M); od: for n from 0 to M do m:=n+digprod(n); lis1[n]:=m; if (m <= M) then lis2[m]:=lis2[m]+1; fi; od: t1:=[seq(lis1[i],i=0..M)]; # A230099 t2:=[seq(lis2[i],i=0..M)]; # A230103 COMPl(t1); # A230104 for i from 1 to M do h:=lis2[i]; if h <= ctmax then ct[h]:=[op(ct[h]),i]; fi; od: len:=nops(ct[0]); [seq(ct[0][i],i=1..len)]; # A230104 again len:=nops(ct[1]); [seq(ct[1][i],i=1..len)]; # A230105
-
PARI
a(n) = if (n==0, return(1)); sum(k=1, n, k+vecprod(digits(k)) == n); \\ Michel Marcus, Sep 18 2020
-
Python
from math import prod def b(n): return n + prod(map(int, str(n))) def a(n): return sum(1 for m in range(n+1) if b(m) == n) print([a(n) for n in range(103)]) # Michael S. Branicky, Jan 09 2023
-
Python
# faster version for initial segment of sequence from math import prod from collections import Counter def b(n): return n + prod(map(int, str(n))) def aupto(n): c = Counter(b(m) for m in range(n+1)) return [c[k] for k in range(n+1)] print(aupto(102)) # Michael S. Branicky, Jan 09 2023
Comments