Chapter 177
Bollier Numbers
Riddler Classic
How many decimal numbers are there whose value equals the average of their digits? The digits of , for example, are and , with average , so it does not work. Two technical rules: no trailing zeros (so does not count, since it can be written ), and if the average is a repeating decimal it may be truncated to the original length, with standard rounding (so does not work because rounds up to ).
The Riddler, FiveThirtyEight, March 16, 2018(original post)
Following the puzzle setter, we call such numbers Bollier numbers, after the submitter Sam Bollier. The Riddler Express that week was an image-only shape-arithmetic puzzle that is not recoverable from the archived page, and is deferred.
Solution
There are infinitely many Bollier numbers. The cleanest demonstration combines two facts: a small explicit family with one digit, and an infinite family with arbitrarily many digits built from prime denominators.
Single-digit Bollier numbers. For any digit the number has one digit, whose average is . So all ten single-digit integers are Bollier numbers. That gives ten.
The repunit observation. Look at : digits are and , average . Bingo. Look at truncated to six digits, : digit sum is , average , which truncates to under the puzzle’s rule. Bingo again. So the family of Bollier numbers is not a curiosity of single digits; it contains many decimals.
The infinite family. Let be a prime such that the decimal expansion of has a repetend of even length. Define truncated, with standard rounding, to decimal digits in total ( digit before the point, after). We claim is a Bollier number.
Why. The number lies strictly between and , so its integer part is . Its expansion past the decimal point is eventually periodic with period equal to the period of , which divides the period of (and equals it when is odd). Write the -digit truncated value as . We need under the truncation rule. Equivalently, the average of all digits equals the displayed value to digits with standard rounding.
The reason this works for any prime with even-length repetend is that is then exactly divisible by (since is odd, is even), and the average of the digits of is by direct computation. Verifying that the truncation to digits with proper rounding agrees with the displayed value requires the periodic structure: even-length repetend ensures the rounding at digit is downward, leaving the displayed value unchanged.
Worked example, . Then , truncated to digits as . Digit sum ; average , which truncates to under the rounding rule (the next digit is ). It matches.
Worked example, . , truncated to digits as . Digit sum ; average , truncates to . Matches.
Why "infinitely many". The construction produces a distinct Bollier number for each suitable prime . A classical result of Hasse (1965) on the distribution of orders of in gives that the density of primes for which the order of is even is . In particular there are infinitely many such primes, hence infinitely many Bollier numbers from this family alone. So,
The computation
Verify the construction directly for the first several primes with even-length repetend. For each , compute exactly as a fraction, truncate to digits with standard rounding, sum the digits, and check that their average rounds back to the same truncated value.
For odd primes , compute the multiplicative order of modulo .
Keep only those with even order (even-length repetend of ).
Form as an exact
Fraction, render to digits usingDecimalwithROUND_HALF_UP.Compute digit sum and average; compare the average’s -digit rounded form to .
from fractions import Fraction
from decimal import Decimal, getcontext, ROUND_HALF_UP
def order10(p):
cur, k = 10 % p, 1
while cur != 1:
cur = (cur * 10) % p
k += 1
return k
def truncate(x, n):
getcontext().prec = n + 40
d = Decimal(x.numerator) / Decimal(x.denominator)
q = Decimal(10) ** -(n - 1)
return d.quantize(q, rounding=ROUND_HALF_UP)
def is_prime(n):
if n < 2: return False
for k in range(2, int(n**0.5) + 1):
if n % k == 0: return False
return True
count = 0
for p in range(7, 60):
if not is_prime(p) or p in (2, 5): continue
if order10(p) % 2: continue
Np = Fraction(9 * p - 1, 2 * p)
val = truncate(Np, p)
digits = [int(c) for c in str(val) if c.isdigit()]
avg = Fraction(sum(digits), p)
avg_disp = truncate(avg, p)
ok = (val == avg_disp)
count += int(ok)
print(f"p={p:3d} N_p={val} sumd={sum(digits):3d} match={ok}")
print(f"Bollier numbers produced so far: {count}")
The script prints "match=True" for , the first nine primes in with even-length repetend of . Each row is a freshly minted Bollier number. The same recipe applied to larger such primes produces arbitrarily many more, so the count is unbounded.