A031347 Multiplicative digital root of n (keep multiplying digits of n until reaching a single digit).
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, 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, 6, 0, 0, 7, 4, 2, 6, 5, 8, 8, 0, 8, 0, 8, 6, 8, 6, 0, 6
Offset: 0
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
- Shyam Sunder Gupta, Digital Root Wonders, Exploring the Beauty of Fascinating Numbers, Springer (2025) Ch. 1, 1-28.
- Eric Weisstein's World of Mathematics, Multiplicative Digital Root.
- Index entries for Colombian or self numbers and related sequences
Crossrefs
Programs
-
Haskell
a031347 = until (< 10) a007954 -- Reinhard Zumkeller, Oct 17 2011, Sep 22 2011
-
Maple
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
-
Mathematica
mdr[n_] := NestWhile[Times @@ IntegerDigits@# &, n, UnsameQ, All]; Table[ mdr[n], {n, 0, 104}] (* Robert G. Wilson v, Aug 04 2006 *) Table[NestWhile[Times@@IntegerDigits[#] &, n, # > 9 &], {n, 0, 90}] (* Harvey P. Dale, Mar 10 2019 *)
-
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)) for(n=1,80, print1(A031347(n),",")) \\ R. J. Mathar, May 23 2006
-
PARI
A031347(n)={while(n>9,n=prod(i=1,#n=digits(n),n[i]));n} \\ M. F. Hasler, Dec 07 2014
-
Python
from operator import mul from functools import reduce def A031347(n): while n > 9: n = reduce(mul, (int(d) for d in str(n))) return n # Chai Wah Wu, Aug 23 2014
-
Python
from math import prod def A031347(n): while n > 9: n = prod(map(int, str(n))) return n print([A031347(n) for n in range(100)]) # Michael S. Branicky, Apr 17 2024
-
Scala
def iterDigitProd(n: Int): Int = n.toString.length match { case 1 => n case => iterDigitProd(n.toString.toCharArray.map( - 48).scanRight(1)( * ).head) } (0 to 99).map(iterDigitProd) // Alonso del Arte, Apr 11 2020
Formula
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
Comments