cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A051802 Nonzero multiplicative digital root of n.

This page as a plain text file.
%I A051802 #34 Apr 20 2020 09:54:38
%S A051802 1,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,2,2,4,6,8,1,2,4,6,8,3,3,6,9,
%T A051802 2,5,8,2,8,4,4,4,8,2,6,2,8,6,6,8,5,5,1,5,2,1,3,5,4,2,6,6,2,8,8,3,8,8,
%U A051802 6,2,7,7,4,2,6,5,8,8,3,8,8,8,6,8,6,4,6
%N A051802 Nonzero multiplicative digital root of n.
%C A051802 Occasionally defined with a(0) = 0.
%D A051802 Discussed Jun 15 1991 on sci.math by Mayne, Rusin, Landrum et al.
%H A051802 T. D. Noe, <a href="/A051802/b051802.txt">Table of n, a(n) for n = 0..1000</a>
%H A051802 <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>
%F A051802 If n == A051801(n) then n else a(A051801(n)).
%p A051802 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
%t A051802 mdr0[n_] := NestWhile[Times @@ (IntegerDigits@# /. 0 -> 1) &, n, UnsameQ, All]; Table[ mdr0@n, {n, 0, 104}] (* _Robert G. Wilson v_, Aug 04 2006 *)
%o A051802 (Haskell)
%o A051802 a051802 = until (< 10) a051801  -- _Reinhard Zumkeller_, Nov 23 2011
%o A051802 (PARI) A051801(n)=my(v=select(k->k>1,digits(n)));prod(i=1,#v,v[i])
%o A051802 a(n)=while(n>9,n=A051801(n)); n \\ _Charles R Greathouse IV_, Nov 20 2012
%o A051802 (Python)
%o A051802 from operator import mul
%o A051802 from functools import reduce
%o A051802 def A051802(n):
%o A051802     if n == 0:
%o A051802         return 1
%o A051802     while n > 9:
%o A051802         n = reduce(mul, (int(d) for d in str(n) if d != '0'))
%o A051802     return n
%o A051802 # _Chai Wah Wu_, Aug 23 2014
%o A051802 (Scala) def zeroLessIterDigitProd(n: Int): Int = n.toString.length match {
%o A051802   case 1 => n
%o A051802   case _ => zeroLessIterDigitProd(n.toString.replace("0", "").toCharArray.map(_ - 48).scanRight(1)(_ * _).head)
%o A051802 } // Note that zeroLessIterDigitProd(0) gives 0, not 1
%o A051802 List(1) ++: (1 to 99).map(zeroLessIterDigitProd) // _Alonso del Arte_, Apr 19 2020
%Y A051802 Uses A051801.
%Y A051802 Cf. A007954.
%K A051802 nonn,easy,base,nice
%O A051802 0,3
%A A051802 _Dan Hoey_, Dec 09 1999
%E A051802 More terms from _Robert G. Wilson v_, Aug 04 2006