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.

A031347 Multiplicative digital root of n (keep multiplying digits of n until reaching a single digit).

This page as a plain text file.
%I A031347 #73 Mar 10 2025 11:50:54
%S A031347 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,2,4,6,8,0,2,4,6,8,0,3,6,9,
%T A031347 2,5,8,2,8,4,0,4,8,2,6,0,8,6,6,8,0,5,0,5,0,0,0,5,0,0,0,6,2,8,8,0,8,8,
%U A031347 6,0,0,7,4,2,6,5,8,8,0,8,0,8,6,8,6,0,6
%N A031347 Multiplicative digital root of n (keep multiplying digits of n until reaching a single digit).
%C A031347 a(n) = 0 for almost all n. - _Charles R Greathouse IV_, Oct 02 2013
%C A031347 More precisely, a(n) = 0 asymptotically almost surely, namely, among others, for all numbers n which have a digit '0', and as n has more and more digits, it becomes increasingly less probable that no digit is equal to zero. (The set A011540 has density 1.) Thus the density of numbers for which a(n) > 0 is zero, although this happens for infinitely many numbers, for example all repunits n = (10^k - 1)/9 = A002275(k). - _M. F. Hasler_, Oct 11 2015
%H A031347 T. D. Noe, <a href="/A031347/b031347.txt">Table of n, a(n) for n = 0..10000</a>
%H A031347 Shyam Sunder Gupta, <a href="https://doi.org/10.1007/978-981-97-2465-9_1">Digital Root Wonders</a>, Exploring the Beauty of Fascinating Numbers, Springer (2025) Ch. 1, 1-28.
%H A031347 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/MultiplicativeDigitalRoot.html">Multiplicative Digital Root</a>.
%H A031347 <a href="/index/Coi#Colombian">Index entries for Colombian or self numbers and related sequences</a>
%F A031347 a(n) = d in {1, ..., 9} if (but not only if) n = (10^k - 1)/9 + (d - 1)*10^m = A002275(k) + (d - 1)*A011557(m) for some k > m >= 0. - _M. F. Hasler_, Oct 11 2015
%p A031347 A007954 := proc(n) return mul(d, d=convert(n,base,10)): end: A031347 := proc(n) local m: m:=n: while(length(m)>1)do m:=A007954(m): od: return m: end: seq(A031347(n),n=0..100); # _Nathaniel Johnston_, May 04 2011
%t A031347 mdr[n_] := NestWhile[Times @@ IntegerDigits@# &, n, UnsameQ, All]; Table[ mdr[n], {n, 0, 104}] (* _Robert G. Wilson v_, Aug 04 2006 *)
%t A031347 Table[NestWhile[Times@@IntegerDigits[#] &, n, # > 9 &], {n, 0, 90}] (* _Harvey P. Dale_, Mar 10 2019 *)
%o A031347 (PARI) A031347(n)=local(resul); if(n<10, return(n) ); resul = n % 10; n = (n - n%10)/10; while( n > 0, resul *= n %10; n = (n - n%10)/10; ); return(A031347(resul))
%o A031347 for(n=1,80, print1(A031347(n),",")) \\ _R. J. Mathar_, May 23 2006
%o A031347 (PARI) A031347(n)={while(n>9,n=prod(i=1,#n=digits(n),n[i]));n} \\ _M. F. Hasler_, Dec 07 2014
%o A031347 (Haskell)
%o A031347 a031347 = until (< 10) a007954
%o A031347 -- _Reinhard Zumkeller_, Oct 17 2011, Sep 22 2011
%o A031347 (Python)
%o A031347 from operator import mul
%o A031347 from functools import reduce
%o A031347 def A031347(n):
%o A031347     while n > 9:
%o A031347        n = reduce(mul, (int(d) for d in str(n)))
%o A031347     return n
%o A031347 # _Chai Wah Wu_, Aug 23 2014
%o A031347 (Python)
%o A031347 from math import prod
%o A031347 def A031347(n):
%o A031347     while n > 9: n = prod(map(int, str(n)))
%o A031347     return n
%o A031347 print([A031347(n) for n in range(100)]) # _Michael S. Branicky_, Apr 17 2024
%o A031347 (Scala) def iterDigitProd(n: Int): Int = n.toString.length match {
%o A031347   case 1 => n
%o A031347   case _ => iterDigitProd(n.toString.toCharArray.map(_ - 48).scanRight(1)(_ * _).head)
%o A031347 }
%o A031347 (0 to 99).map(iterDigitProd) // _Alonso del Arte_, Apr 11 2020
%Y A031347 Cf. A007954, A007953, A003001, A010888 (additive digital root of n), A031286 (additive persistence of n), A031346 (multiplicative persistence of n).
%Y A031347 Numbers having multiplicative digital roots 0-9: A034048, A002275, A034049, A034050, A034051, A034052, A034053, A034054, A034055, A034056.
%K A031347 nonn,base,easy,nice
%O A031347 0,3
%A A031347 _Eric W. Weisstein_