A358351 Number of values of m such that m + (sum of digits of m) + (product of digits of m) is n.
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, 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, 1, 0, 0, 0, 1, 2, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 2, 0
Offset: 1
Examples
A161351(15) = 15 + (1+5) + (1*5) = 26 = 21 + (2+1) + (2*1) = A161351(21), so, a(26) = 2.
Programs
-
Mathematica
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 *)
-
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
-
Python
from itertools import combinations_with_replacement from math import prod def A358351(n): c = set() for l in range(1,len(str(n))+1): l1, l2 = 10**l, 10**(l-1) for d in combinations_with_replacement(tuple(range(10)),l): s, p = sum(d), prod(d) if l1>(m:=n-s-p)>=l2 and sorted(int(d) for d in str(m)) == list(d): c.add(m) return len(c) # Chai Wah Wu, Nov 20 2022
Comments