OFFSET
0,3
LINKS
Zak Seidov and Michael De Vlieger, Table of n, a(n) for n = 0..10000 (First 1000 terms from Zak Seidov)
FORMULA
a(n) = 1 if n=0, otherwise a(floor(n/10)) * (n mod 10 + 0^(n mod 10)). - Reinhard Zumkeller, Oct 13 2009
G.f. A(x) satisfies: A(x) = (1 + x + 2*x^2 + 3*x^3 + 4*x^4 + 5*x^5 + 6*x^6 + 7*x^7 + 8*x^8 + 9*x^9) * A(x^10). - Ilya Gutkovskiy, Nov 14 2020
EXAMPLE
a(0) = 1 since an empty product is 1 by convention. a(120) = 1*2 = 2.
MAPLE
A051801 := proc(n) local d, j: d:=convert(n, base, 10): return mul(`if`(d[j]=0, 1, d[j]), j=1..nops(d)): end: seq(A051801(n), n=0..100); # Nathaniel Johnston, May 04 2011
MATHEMATICA
(Times@@Cases[IntegerDigits[#], Except[0]])&/@Range[0, 80] (* Harvey P. Dale, Jun 20 2011 *)
Table[Times@@(IntegerDigits[n]/.(0->1)), {n, 0, 80}] (* Harvey P. Dale, Apr 16 2023 *)
PROG
(Haskell)
a051801 0 = 1
a051801 n = (a051801 n') * (m + 0 ^ m) where (n', m) = divMod n 10
-- Reinhard Zumkeller, Nov 23 2011
(PARI) a(n)=my(v=select(k->k>1, digits(n))); prod(i=1, #v, v[i]) \\ Charles R Greathouse IV, Nov 20 2012
(Python)
from operator import mul
from functools import reduce
def A051801(n):
return reduce(mul, (int(d) for d in str(n) if d != '0')) if n > 0 else 1 # Chai Wah Wu, Aug 23 2014
(Python)
from math import prod
def a(n): return prod(int(d) for d in str(n) if d != '0')
print([a(n) for n in range(74)]) # Michael S. Branicky, Jul 18 2021
(Swift) // Swift 5
A051801(n): String(n).compactMap{$0.wholeNumberValue == 0 ? 1 : $0.wholeNumberValue}.reduce(1, *) // Egor Khmara, Jan 15 2021
CROSSREFS
KEYWORD
nonn,easy,base,nice
AUTHOR
Dan Hoey, Dec 09 1999
STATUS
approved