Multiplicative Persistence
The multiplicative persistence of n is the number of times you must multiply the digits of n until reaching a single digit. Find the sum of all n < 10^7 with multiplicative persistence exactly 4.
Problem Statement
This archive keeps the full statement, math, and original media on the page.
We call a triangle

Triangle \(ABC\) above is an example of a fortunate triangle with sides \((6,7,8)\). The distance from the vertex \(C\) to the circumcentre \(O\) is \(\approx 4.131182\), while the distance from \(C\) to the orthocentre \(H\) is half that, at \(\approx 2.065591\).
Define \(S(P)\) to be the sum of \(a+b+c\) over all fortunate triangles with sides \(a\leq b\leq c\) and perimeter not exceeding \(P\).
For example \(S(10)=24\), arising from three triangles with sides \((1,2,2)\), \((2,3,4)\), and \((2,4,4)\). You are also given \(S(100)=3331\).
Find \(S(10^7)\).
Problem 919: Multiplicative Persistence
Mathematical Analysis
Multiplicative Digital Root Process
Definition. The multiplicative persistence of a positive integer is the number of iterations of the digit-product function needed to reach a single digit ().
Examples:
- : .
- : .
- : .
- : .
Guaranteed Termination
Theorem. For any , . Hence the persistence is well-defined and finite.
Proof. If any digit is 0, . Otherwise, for a -digit number (), while . Since , this ratio is less than 9 and decreasing, so for all with digits. For : and ; we verify directly that for , and for by inspection (the only case where could equal would be an Armstrong-like number, but none exist for products in 2 digits).
Erdos Conjecture on Persistence
Conjecture (Erdos). The multiplicative persistence of in base 10 is .
The known record-holders (smallest with given persistence):
| Persistence | Smallest |
|---|---|
| 0 | 0 |
| 1 | 10 |
| 2 | 25 |
| 3 | 39 |
| 4 | 77 |
| 5 | 679 |
| 6 | 6788 |
| 7 | 68889 |
| 8 | 2677889 |
| 9 | 26888999 |
| 10 | 3778888999 |
| 11 | 277777788888899 |
No number with persistence has been found.
Digit Products and 7-Smoothness
Lemma. If has no digit 0, then is 7-smooth (all prime factors ).
Proof. The digit product is a product of single digits from , all of which factor into primes .
Corollary. After the first application of (assuming no zero digit), all subsequent orbit values are 7-smooth.
Zero Digit Shortcut
Lemma. If has a digit 0, then .
Proof. (single digit), done in one step.
This means for target persistence 4, we can skip all numbers containing digit 0.
Worked Example: Persistence 4
Four steps to reach a single digit, so .
Distribution of Persistence Values
For :
- Persistence 0: 10 numbers (single digits)
- Persistence 1: ~4825 numbers (those with a 0 digit, plus direct single-digit products)
- Persistence 2: ~3558 numbers
- Persistence 3: ~1484 numbers
- Persistence 4: ~116 numbers
- Persistence 5: ~6 numbers
- Persistence 6: ~1 number (6788)
The density of high-persistence numbers decreases rapidly.
Proof of Correctness
- Termination: for , so the iteration always terminates.
- Exhaustiveness: We check every .
- Digit extraction: Standard modular arithmetic correctly extracts digits.
- Summation: We accumulate (not ) when .
Complexity Analysis
- Per-number cost: where is the persistence.
- Total: for .
- Space: extra (no memoization needed).
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
/*
* Problem 919: Multiplicative Persistence
*
* Find the sum of all n < 10^7 with multiplicative persistence exactly 4.
*
* Multiplicative persistence: repeatedly replace n by the product of its
* digits until reaching a single digit. Count the steps.
*
* Key facts:
* - f(n) < n for n >= 10, so persistence is finite.
* - Numbers with digit 0 have persistence 1 (f(n) = 0 immediately).
* - Erdos conjecture: persistence = O(log log n).
* - Record: persistence 11 at n = 277777788888899.
*
* Complexity: O(N * log N) time, O(1) space.
*/
int digit_product(int n) {
int p = 1;
while (n > 0) {
p *= n % 10;
n /= 10;
}
return p;
}
int persistence(int n) {
int c = 0;
while (n >= 10) {
n = digit_product(n);
c++;
}
return c;
}
int main() {
const int N = 10000000;
const int TARGET = 4;
long long total = 0;
for (int n = 10; n < N; n++) {
if (persistence(n) == TARGET) {
total += n;
}
}
cout << total << endl;
// Verification: known smallest values with each persistence
assert(persistence(77) == 4); // 77->49->36->18->8
assert(persistence(679) == 5); // 679->378->168->48->32->6
assert(persistence(6788) == 6);
assert(persistence(68889) == 7);
return 0;
}
"""
Problem 919: Multiplicative Persistence
The multiplicative persistence of n is the number of times you multiply
digits of n until reaching a single digit. Find sum of all n < 10^7
with persistence exactly 4.
Key ideas:
- f(n) = product of digits of n; iterate until single digit.
- For n >= 10, f(n) < n, so persistence is finite.
- Numbers with digit 0 have persistence 1 (skip for target 4).
- Erdos conjecture: persistence = O(log log n).
- Smallest n with persistence 11: 277777788888899.
Methods:
1. Direct computation for each n in [10, 10^7)
2. Optimized: skip numbers containing digit 0
"""
from collections import Counter
# Core functions
def digit_product(n: int) -> int:
"""Product of digits of n."""
p = 1
while n > 0:
p *= n % 10
n //= 10
return p
def persistence(n: int) -> int:
"""Multiplicative persistence of n."""
count = 0
while n >= 10:
n = digit_product(n)
count += 1
return count
def solve(N: int = 10**7, target: int = 4) -> int:
"""Sum of all n < N with multiplicative persistence = target."""
total = 0
for n in range(10, N):
if persistence(n) == target:
total += n
return total
def solve_optimized(N: int = 10**7, target: int = 4) -> int:
"""Same as solve but skips n with digit 0 (persistence 1)."""
total = 0
for n in range(10, N):
# Quick check: if any digit is 0, persistence is 1
temp = n
has_zero = False
while temp > 0:
if temp % 10 == 0:
has_zero = True
break
temp //= 10
if has_zero:
continue
if persistence(n) == target:
total += n
return total
# Solve
answer = solve()
print(answer)
# Verification
# Known smallest numbers with each persistence
smallest_known = {0: 0, 1: 10, 2: 25, 3: 39, 4: 77, 5: 679, 6: 6788, 7: 68889}
for pers, val in smallest_known.items():
assert persistence(val) == pers, f"persistence({val}) should be {pers}"
# Verify persistence(77) = 4: 77 -> 49 -> 36 -> 18 -> 8
assert digit_product(77) == 49
assert digit_product(49) == 36
assert digit_product(36) == 18
assert digit_product(18) == 8