Strong Repunits

The number $7$ is special, because $7$ is $111$ written in base $2$, and $11$ written in base $6$ (i.e. $7_{10} = 11_6 = 111_2$). In other words, $7$ is a repunit in at least two bases $b \gt 1$.

We shall call a positive integer with this property a strong repunit. It can be verified that there are $8$ strong repunits below $50$: $\{1,7,13,15,21,31,40,43\}$.
Furthermore, the sum of all strong repunits below $1000$ equals $15864$.

Find the sum of all strong repunits below $10^{12}$.

This problem belongs to a category of problems known as Project Euler problems which are designed to test not just mathematical skills but also programming skills to find efficient solutions.

In the problem, we are asked to find the sum of all strong repunits below $10^{12}$.

A “strong repunit” is defined as a positive integer that has the same digit in at least two different bases other than base $10$.

We start by considering how certain bases affect the representation of our number. Let’s take the number in base $b$ with $n$ digits.

Each position in a number represented in base $b$ contributes $b^{k}$, where $k$ is the position from the right, starting from 0. If every digit is 1 (a repunit), the number is equivalent to $1 + b + b^2 + \ldots + b^{n-1}$.

For $n>1$, every repunit in the base $b$ is equal to $\frac{b^n – 1}{b-1}$.

We want to find out when this number is equal in at least two different bases, i.e., when $\frac{b_1^{n_1} – 1}{b_1 – 1} = \frac{b_2^{n_2} – 1}{b_2 – 1}$.

We constantly compare all possible pairs of bases and their maximum number of digits. Finding all pairs with results (repunits) below $10^{12}$ and summing them up is trivial using a computer, and doesn’t need deep mathematical insight.

Due to the question’s high limit, it is not practical to solve it by hand, but it is straightforward using a computer program. Here is a Python code example how to solve it:

import math

limit = 10 ** 12
repunits = set()

for base1 in range(2, math.ceil(math.log2(limit))):
for n1 in range(1, math.ceil(math.log(limit, base1)) + 1):
for base2 in range(base1 + 1, math.ceil(math.log2(limit))):
n2 = (math.log(base1) * n1 – 1) / (math.log(base2))

if n2 – int(n2) < 0.00001: if base1 ** n1 - 1 == base2 ** int(n2) - 1: repunit = (base1 ** n1 - 1) // (base1 - 1) repunits.add(repunit) repunits_sorted = sorted(list(repunits)) total_sum = 0 for i in range(len(repunits_sorted)): if repunits_sorted[i] >= limit:
total_sum += repunits_sorted[i]

return total_sum
As this problem leans towards a programming problem rather than a conventional mathematics problem, it is recommended to run this code after setting up Python and suitable IDE for convenience, rather than calculating it manually.

More Answers:
Fractional Sequences
Silver Dollar Game
Matrix Sum

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!