login
Number of values of m such that m + (sum of digits of m) + (product of digits of m) is n.
3

%I #25 Nov 21 2022 02:58:50

%S 0,0,1,0,0,1,0,0,1,0,1,1,0,1,1,0,1,1,0,1,1,1,1,1,0,2,1,0,1,1,0,1,1,1,

%T 1,0,0,3,0,0,0,1,1,1,0,1,0,1,0,2,0,0,1,1,1,1,0,2,0,0,0,2,1,0,0,1,0,2,

%U 1,0,0,0,1,2,0,1,1,1,0,1,0,1,1,0,0,2,0

%N Number of values of m such that m + (sum of digits of m) + (product of digits of m) is n.

%C a(n) is the number of times n occurs in A161351.

%C a(n) > 0 iff n is in A358350.

%e A161351(15) = 15 + (1+5) + (1*5) = 26 = 21 + (2+1) + (2*1) = A161351(21), so, a(26) = 2.

%t f[n_] := n + Total[(d = IntegerDigits[n])] + Times @@ d; With[{m = 100}, BinCounts[Table[f[n], {n, 1, m}], {1, m, 1}]] (* _Amiram Eldar_, Nov 16 2022 *)

%o (PARI) first(n) = {my(res = vector(n)); for(i = 1, n, c = i + sumdigits(i) + vecprod(digits(i)); if(c <= n, res[c]++ ) ); res } \\ _David A. Corneth_, Nov 16 2022

%o (Python)

%o from itertools import combinations_with_replacement

%o from math import prod

%o def A358351(n):

%o c = set()

%o for l in range(1,len(str(n))+1):

%o l1, l2 = 10**l, 10**(l-1)

%o for d in combinations_with_replacement(tuple(range(10)),l):

%o s, p = sum(d), prod(d)

%o if l1>(m:=n-s-p)>=l2 and sorted(int(d) for d in str(m)) == list(d):

%o c.add(m)

%o return len(c) # _Chai Wah Wu_, Nov 20 2022

%Y Cf. A011540, A161351, A358350.

%Y Similar: A230093 (m+digitsum), A230103 (m+digitprod).

%K nonn,base

%O 1,26

%A _Bernard Schott_, Nov 16 2022