# Numbers that are averages of their digits

A number is called special if its decimal value^ is the average of its digits. How many special numbers are there? Bonus: How many special numbers do not begin with the digit 0? Good luck!

^ You are allowed to append zeroes at the end. For example "1" is a special number, while "1.0" is not.

• Are you saying that, for example, 0.200000000 is special? Sep 23 at 10:01
• @hexomino that's right! Sep 23 at 10:20
• I feel like the bonus is the real interesting question here. As the answers demonstrate, the original is borderline trivial. Would also be interesting to see what happens if we exclude trailing zeroes. Sep 23 at 10:37
• What would be really interesting is any rational numbers with an infinitely repeating decimal expansion that would fit this rule Sep 23 at 11:29
• @BenjaminWang: I suppose the average of the digits of any normal number (in the sense of the limit of the digit average as you take more & more digits) would have to be 9/2. And since 9/2 isn't normal, and "most" real numbers are normal, then any numbers with this property are very special indeed. Sep 25 at 18:55

For the bonus, single-digit integers are trivial.

Rational numbers greater than 1, with trailing zeros, include:

1.1250000 = 9/8
1.500 = 6/4
1.687500000000000 = 27/16
1.8000 = 9/5
2.250 = 9/4
3.750 = 15/4

And this one is very special, having no trailing zeros.

4.5 = 9/2

• Nice work! These are all that I found, including one extra (third one). Are there any more? Sep 23 at 13:25
• I found the same ones. I don't think there are any others of finite length, cause with longer numbers you get a larger proportion of trailing zeroes, bringing the average of the digits to below 1. Sep 23 at 14:20
• The numerators are all divisible by 3. Interesting. Sep 23 at 15:08
• @BenjaminWang yes, it's possible to show that (in any special number) the sum of digits must be a multiple of 3 unless the number of digits is 1 mod 9. So a special number with digit sum not divisible by 3 has either 10 digits or at least 64 digits, and therefore has too many zeroes to be above 1. Sep 26 at 11:38

There

are an infinite number of special numbers,

because

0.1...0 (total 10 digits), 0.01...0 (total 100 digits), and so on all work.

For the bonus part, I found

1, 2, ..., 9, and...

If you allow infinite decimals, we have 8.999... recurring.

• There are more special numbers that do not begin with 0 Sep 23 at 10:52
• Yea I made a mistake in the bonus part. Will try again. Sep 23 at 10:54
• nice find. There are more... Sep 23 at 11:38

There are

an infinite number of special numbers.

For example,

0, 0.0, 0.00, ...

• but these are all the same number! Sep 25 at 12:41
• @univalence The question states, “For example "1" is a special number, while "1.0" is not.” So the appearance of a number (and not just its value) is important in this question. So 0, 0.0, 0.00, … are different special numbers. Sep 26 at 2:57

I wanted to try my hand at it from a principled way, by creating an equation for it.

The simple case of single digits is obvious, so let's start our equations with 2 digits of interest: ie, we are looking for (a, b, n) such that a.b0... = (a + b) / n.

a + b / 10 = (a + b) / n
<=> n . a + n . b / 10 = a + b
<=> (n - 1) . a = (1 - n / 10) . b
<=> a = b . (1 - n / 10) / (n - 1)

Now, we can attempt to solve the equation for various values of n:

We restrict ourselves to a and b in [1, 2, 3, 4, 5, 6, 7, 8, 9], as a = 0 or b = 0 are trivial cases.

- For n = 2 we get a = b . 4 / 5, and thus a = 4 and b = 5, that is: 4.5 = 9 / 2.
- For n = 3 we get a = b . 7 / 20, and no value of b will make up that 20.
- For n = 4 we get a = b / 5, and thus a = 1 and b = 5, that is: 1.500 = 6 / 4.
- For n = 5 we get a = b / 8, and thus a = 1 and b = 8, that is: 1.8000 = 9 / 5.
- For n = 6 we get a = b . 2 / 25, and no value of b will make up that 25.
- For n = 7 we get a = b / 20, and no value of b will make up that 20.
- For n = 8 we get a = b / 35, and no value of b will make up that 35.

Given the fact that the denominator will only grow from there, and that the quotient b / a cannot exceed 9, there's no point in looking any further.

As a recap, we have gathered the following solutions:

4.5 = 9 / 2, 1.500 = 6 / 4, and 1.8000 = 9 / 5.

We can similarly proceed with (a, b, c, n) such at a.bc0... = (a + b + c) / n.

a + b / 10 + c / 100 = (a + b + c) / n
<=> n . a + n . b / 10 + n . c / 100 = a + b + c
<=> (n - 1) . a = (1 - n / 10) . b + (1 - n / 100) . c
<=> a = (b . (1 - n / 10) + c . (1 - n / 100)) / (n - 1)

Which we can once again attempt to solve for various values of n:

We restrict ourselves to: - a and c being non-zero digits, otherwise we fall back to the previous study. - while b can be any digit. And from there: - For n = 3 we get a = (b . 70 + c . 97) / 200, and just looking at the digits of the numerator tells us there's no solution with c non-zero. - For n = 4 we get a = (b . 15 + c . 24) / 75, once again, looking at the digits of the numerator, we notice that there's no solution with c != 5. With c = 5, we find a = 2 and b = 2, that is: 2.250 = 9 / 4, as well as a = 3 and b = 7, that is 3.750 = 15 / 4.
- For n = 5 we get a = (b . 10 + c . 19) / 80, and just looking at the digits of the numerator tells us there's no solution with c non-zero.
- For n = 6 we get a = (b . 20 + c . 47) / 250, nope.
- For n = 7 we get a = (b . 10 + c . 31) / 200, nope.
- For n = 8 we get a = (b . 5 + c . 23) / 175, no solution with c != 5, and the denominator is too large for b to make it up when c = 5.
- For n = 9 we get a = (b . 10 + c . 91) / 800, nope. - For n = 10 we get a = c / 10, and the denominator has grown too large for c to make up.

As a recap, we have gathered the following solutions:

2.250 = 9 / 4, and 3.750 = 15 / 4.

Observation:

It seems that in a multi-digits solution, there cannot be a solution in which the smallest non-zero digit is not 5, as otherwise it doesn't add-up cleanly with the previous smallest digit.

Automating the search with Python does not yield any more results beyond:

- For 4 digits, we find for n = 8, a = 1, b = 1, c = 2, and d = 5, or 1.1250000 = 9 / 8.
- For 5 digits, we find 1.6875 = 27 / 16.

And I do wish I had a more principled explanation for this.

Program:

    from fractions import Fraction

def solve_rec(n, n_digits):
def rec(n, den, fac, digits, acc):
if den == fac:
denominator = den * (n - 1)

if acc <= 0 or acc % denominator != 0:
return

a = acc // denominator

digits = [a] + digits

print("n = ", n, ", list = ", digits, ", fraction =", sum(digits), "/", n)
return

numerator = den - fac * n

for digit in range(0, 10):
new_acc = acc + digit * numerator

if new_acc % (fac * 10) != 0:
continue

rec(n, den, fac * 10, [digit] + digits, new_acc)

last_numerator = 10 ** n_digits - n

for last in range(1, 10):
accumulator = last * last_numerator

if accumulator % 10 != 0:
continue

rec(n, 10 ** n_digits, 10, [last], accumulator)

if name == 'main':
import sys

limit = int(sys.argv)

for n_digits in range(1, 10):
for n in range(n_digits + 1, limit + 1):
solve_rec(n, n_digits)