Wolfram Research

Function Repository Resource:

MultiplicativeDigitalRoot (1.0.0) current version: 1.1.0 »

Source Notebook

Compute the multiplicative digital root of an integer

Contributed by: Christopher Stover

ResourceFunction["MultiplicativeDigitalRoot"][n]

returns the multiplicative digital root of n.

Details

Starting with a non-negative integer n, multiply its digits, then multiply the digits of the resulting number, etc., until the result has only one digit. The one-digit integer marking the stopping point of this process is called the multiplicative digital root of n.
As an example, consider n=14691:
Multiplying its digits yields 1×4×6×9×1=216.
Multiplying the digits of the result yields 2×1×6=12.
Multiplying the digits of the result yields 1×2=2. Because 2 is a single-digit number, the process stops.
Because the integer marking the termination of the process is 2, ResourceFunction["MultiplicativeDigitalRoot"][14691] returns 2.
ResourceFunction["MultiplicativeDigitalRoot"] threads elementwise over lists.

Examples

Basic Examples (1) 

Verify the result claimed in the Details section:

In[1]:=
ResourceFunction["MultiplicativeDigitalRoot"][14691]
Out[1]=

Scope (2) 

MultiplicativeDigitalRoot threads elementwise over lists:

In[2]:=
ResourceFunction["MultiplicativeDigitalRoot"][{13, 248, 66677, 89}]
Out[2]=

Compute the multiplicative digital root of the first 100 integers (OEIS A031347):

In[3]:=
ResourceFunction["MultiplicativeDigitalRoot"] /@ Range[0, 99, 1]
Out[3]=

Properties and Relations (4) 

The result returned by MultiplicativeDigitalRoot can be manually computed using NestWhileList:

In[4]:=
With[{n = 8675309}, ResourceFunction["MultiplicativeDigitalRoot"][n] == NestWhileList[Times @@ IntegerDigits[#] &, n, # >= 10 &][[-1]]]
Out[4]=

The multiplicative digital root of an integer can also be manually computed with no high-level functions:

In[5]:=
testint1 = 1234
Out[5]=
In[6]:=
digits1 = IntegerDigits[testint1]
Out[6]=
In[7]:=
testint2 = Times @@ digits1
Out[7]=
In[8]:=
digits2 = IntegerDigits[testint2]
Out[8]=
In[9]:=
testint3 = Times @@ digits2
Out[9]=

Because testint3 is a single-digit integer, the process terminates here, and because testint3 equals 8, the multiplicative digital root of testint1=1234 is equal to 8:

In[10]:=
ResourceFunction["MultiplicativeDigitalRoot"][testint1]
Out[10]=

The number of iterations required to reach the end of the digit multiplication process is called the multiplicative persistence and is returned by the resource function MultiplicativePersistence:

In[11]:=
n = 13579
Out[11]=
In[12]:=
list = NestWhileList[Times @@ IntegerDigits[#] &, n, # >= 10 &]
Out[12]=
In[13]:=
ResourceFunction["MultiplicativeDigitalRoot"][n] == list[[-1]]
Out[13]=
In[14]:=
ResourceFunction["MultiplicativePersistence"][n] == Length[list] - 1
Out[14]=

The additive analogue of the multiplicative digital root is called the additive digital root and is returned by the resource function AdditiveDigitalRoot:

In[15]:=
n2 = 2111971
Out[15]=
In[16]:=
{add, mult} = Function[f, NestWhileList[f @@ IntegerDigits[#] &, n2, # >= 10 &]] /@ {Plus, Times}
Out[16]=
In[17]:=
ResourceFunction["MultiplicativeDigitalRoot"][n2] == mult[[-1]]
Out[17]=
In[18]:=
ResourceFunction["AdditiveDigitalRoot"][n2] == add[[-1]]
Out[18]=

Possible Issues (1) 

MultiplicativeDigitalRoot requires its input to be non-negative:

In[19]:=
ResourceFunction["MultiplicativeDigitalRoot"][-234545]
Out[19]=

Neat Examples (1) 

Create a OEIS-themed table showing which integers have the same multiplicative digital root. This partially reproduces a cool result from the associated MathWorld article:

In[20]:=
Table[Shallow[
   Select[Range[0, 10000, 1], ResourceFunction["MultiplicativeDigitalRoot"][#] == n &]], {n, 0, 9, 1}] // Column
Out[20]=

Publisher

therealcstover

Version History

  • 1.1.0 – 25 May 2023
  • 1.0.0 – 09 August 2022

Related Resources

Author Notes

Future versions of this will likely contain expansion to allow for integers in bases other than 10.
As mentioned on the page Problems & Puzzles, Puzzle 341, there is a modified definition of multiplicative persistence due to Erdős wherein one only multiplies the nonzero digits at each step. This modification is not implemented herein but may be included in a future update.
In a future update, I'm going to make the "Neat Examples" table look better. That's definitely a version 2 edit!

License Information