OFFSET
0,3
COMMENTS
Occasionally defined with a(0) = 0.
REFERENCES
Discussed Jun 15 1991 on sci.math by Mayne, Rusin, Landrum et al.
LINKS
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: A051802 := proc(n) local m: if(n=0)then return 1:fi: m:=n: while(length(m)>1)do m:=A051801(m): od: return m: end: seq(A051802(n), n=0..100); # Nathaniel Johnston, May 04 2011
MATHEMATICA
mdr0[n_] := NestWhile[Times @@ (IntegerDigits@# /. 0 -> 1) &, n, UnsameQ, All]; Table[ mdr0@n, {n, 0, 104}] (* Robert G. Wilson v, Aug 04 2006 *)
PROG
(Haskell)
a051802 = until (< 10) a051801 -- Reinhard Zumkeller, Nov 23 2011
(PARI) A051801(n)=my(v=select(k->k>1, digits(n))); prod(i=1, #v, v[i])
a(n)=while(n>9, n=A051801(n)); n \\ Charles R Greathouse IV, Nov 20 2012
(Python)
from operator import mul
from functools import reduce
def A051802(n):
if n == 0:
return 1
while n > 9:
n = reduce(mul, (int(d) for d in str(n) if d != '0'))
return n
# Chai Wah Wu, Aug 23 2014
(Scala) def zeroLessIterDigitProd(n: Int): Int = n.toString.length match {
case 1 => n
case _ => zeroLessIterDigitProd(n.toString.replace("0", "").toCharArray.map(_ - 48).scanRight(1)(_ * _).head)
} // Note that zeroLessIterDigitProd(0) gives 0, not 1
List(1) ++: (1 to 99).map(zeroLessIterDigitProd) // Alonso del Arte, Apr 19 2020
CROSSREFS
KEYWORD
nonn,easy,base,nice
AUTHOR
Dan Hoey, Dec 09 1999
EXTENSIONS
More terms from Robert G. Wilson v, Aug 04 2006
STATUS
approved