Function Repository Resource:

MultiplicativePersistence

Source Notebook

Compute the multiplicative persistence, in any base, of an integer

Contributed by: Christopher Stover

ResourceFunction["MultiplicativePersistence"][n,b]

gives the multiplicative persistence of the non-negative integer n when expressed in the base b.

ResourceFunction["MultiplicativePersistence"][n]

gives the base-10 muliplicative persistence of n.

Details

Starting with a non-negative integer n, multiply its base-b digits, then multiply the digits of the resulting number, etc., until the result has only one digit. The number of multiplications required to reach the single digit stopping point is called the multiplicative persistence of n.
As an example in base 10, 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 it took three steps to reach the stopping point, ResourceFunction["MultiplicativePersistence"][14691] returns 3.
The multiplicative persistence of a number is also sometimes called its number length.
ResourceFunction["MultiplicativePersistence"] threads elementwise over lists.

Examples

Basic Examples (2) 

Compute the multiplicative persistence of 14691:

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

Compute the multiplicative persistence of 14691, base-14:

In[2]:=
ResourceFunction["MultiplicativePersistence"][14691, 14]
Out[2]=

Scope (2) 

MultiplicativePersistence threads elementwise over lists:

In[3]:=
listIn = {13, 54321, 66677, 8989119898};
ResourceFunction["MultiplicativePersistence"][listIn]
Out[4]=
In[5]:=
ResourceFunction["MultiplicativePersistence"][listIn, 7]
Out[5]=

Compute the multiplicative persistence of the first 100 integers (OEIS A031346):

In[6]:=
ResourceFunction["MultiplicativePersistence"] /@ Range[0, 99]
Out[6]=

Properties and Relations (3) 

The result returned by MultiplicativePersistence can be iteratively computed using NestWhileList:

In[7]:=
With[{n = RandomInteger[10^9], b = RandomInteger[{2, 20}]}, ResourceFunction["MultiplicativePersistence"][n, b] == Length[NestWhileList[Times @@ IntegerDigits[#, b] &, n, # >= b &]] - 1]
Out[7]=

The single-digit integer that marks the end of the digit multiplication process is called the multiplicative digital root and is returned by the resource function MultiplicativeDigitalRoot:

In[8]:=
n = RandomInteger[10^7]
Out[8]=
In[9]:=
list = NestWhileList[Times @@ IntegerDigits[#] &, n, # >= 10 &]
Out[9]=
In[10]:=
ResourceFunction["MultiplicativeDigitalRoot"][n] == list[[-1]]
Out[10]=

The additive analogue of multiplicative persistence is called additive persistence and is returned by the resource function AdditivePersistence:

In[11]:=
n = RandomInteger[10^7]
Out[11]=
In[12]:=
{add, mult} = Function[f, NestWhileList[f @@ IntegerDigits[#] &, n, # >= 10 &]] /@ {Plus, Times}
Out[12]=
In[13]:=
ResourceFunction["AdditivePersistence"][n] == Length[add] - 1
Out[13]=

Possible Issues (1) 

MultiplicativePersistence requires its input to be non-negative:

In[14]:=
ResourceFunction["MultiplicativePersistence"][-234545]
Out[14]=

Neat Examples (1) 

The smallest integers with multiplicative persistences equal to 0,1,2,3,4, (OEIS A003001) are:

In[15]:=
ResourceFunction[
 "MultiplicativePersistence"][{10, 25, 39, 77, 679, 6788, 68889, 2677889, 26888999, 3778888999, 277777788888899}]
Out[15]=

It is known that there is no number N<10233 with multiplicative persistence larger than 11 (Carmody 2001).

Version History

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

Source Metadata

Related Resources

Author Notes

Extensions, including those mentioned in the corresponding MathWorld article, will may also be included in a future update.
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.

License Information