Average digit sum – 2

I choose some positive integer b b and write down all nonnegative integers (so 0 is included) less than b 3 b^3 in one list, but I write them in base b b , and then all nonnegative integers less than b 7 b^7 in another list, also written in base b b . Then I compute the average digit sum of all numbers in the first list and the average digit sum of all numbers in the second list. These two averages have a difference of 2018 (in base 10).

Which integer b b did I choose?

Other parts


The answer is 1010.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

David Vreken
Dec 13, 2018

Let us first find a general equation for the average of all the digit sums of all nonnegative integers less than b n b^n written down in base b b .

Including zeroes as leading digits, there are n b n nb^n total digits. Since they all appear equally, each digit from 0 0 to b b appears n b n b \frac{nb^n}{b} times, which makes the sum of all the digits n b n ( 0 + 1 + 2 + . . . + ( b 1 ) ) b \frac{nb^n(0 + 1 + 2 + ... + (b - 1))}{b} and the average of all the digit sums n b n ( 0 + 1 + 2 + . . . + ( b 1 ) ) b b n \frac{nb^n(0 + 1 + 2 + ... + (b - 1))}{b \cdot b^n} or n ( 0 + 1 + 2 + . . . + ( b 1 ) ) b \frac{n(0 + 1 + 2 + ... + (b - 1))}{b} .

The sum 0 + 1 + 2 + . . . + ( b 1 ) 0 + 1 + 2 + ... + (b - 1) can be expressed as b ( b 1 ) 2 \frac{b(b - 1)}{2} . Substituting this in, the average of all the digit sums is now n ( b ( b 1 ) 2 ) b \frac{n(\frac{b(b - 1)}{2})}{b} or n ( b 1 ) 2 \frac{n(b - 1)}{2} .

This means that the average of all the digit sums of all the nonnegative integers less than b 7 b^7 is 7 ( b 1 ) 2 \frac{7(b - 1)}{2} , and the average of all the digit sums of all the nonnegative integers less than b 3 b^3 is 3 ( b 1 ) 2 \frac{3(b - 1)}{2} , for a difference of 7 ( b 1 ) 2 3 ( b 1 ) 2 = 2 b 2 \frac{7(b - 1)}{2} - \frac{3(b - 1)}{2} = 2b - 2 . Equating this to 2018 2018 , 2 b 2 = 2018 2b - 2 = 2018 , which solves to b = 1010 b = \boxed{1010} .

how did you compute the toal number of digits at the begining of the problem

Venkatesh A - 2 years, 5 months ago

Log in to reply

There would be b n b^n numbers at n n digits each. For example, for the number of digits less than 1 0 2 10^2 in base 10 10 (i.e. the numbers 00-99) there are 100 100 numbers at 2 2 digits each, for a total of 200 200 digits.

David Vreken - 2 years, 5 months ago

Log in to reply

how can we say that, all the digits will appear equally?

Venkatesh A - 2 years, 5 months ago

Log in to reply

@Venkatesh A All numbers up to b n b^n include every variation of the digits 0 0 to b b , so every digit will appear equally.

David Vreken - 2 years, 5 months ago

This is brilliant.

CodeCrafter 1 - 2 years, 1 month ago

The main idea, that I also used for the harder version, is as bellow. I think, with the hard one, if you take my approach, you eventually need to make some approximation and reaching the actual solution is rather difficult (I am prone to make mistakes though).

In any base b b , there are b b symbols { 0 , 1 , , ( b 1 ) } \{0,1,\dots , (b-1)\} . The number of times a symbol k k is used, in numbers from 0 0 to p t p^t , is denoted by n k ( t ) n_{k}(t) . It can be shown that n k ( t ) k = 1 , , ( b 1 ) n_{k}(t) \ \forall k=1,\dots, (b-1) is the same, when t t is fixed, except for n 0 ( t ) = n k ( t ) 2 k = 1 , , p 1 n_{0}(t)=\frac{n_{k}(t)}{2} \ k=1,\dots,p-1 . So, if we know how many digits have been used in numbers from 0 0 to p t p^t (denoted by N ( t ) N(t) ), then we would know n k ( t ) k n_{k}(t) \ \forall \ k .

N ( t ) = b + 2 t j ( b j b j 1 ) = t . b t b t b b 1 N(t)=b+\sum_{2}^{t} j(b^j-b^{j-1})=t.b^{t}-\frac{b^t-b}{b-1}

which should be equal to

j = 0 b 1 n j ( t ) = 45 2 n 1 ( t ) \sum_{j=0}^{b-1}n_{j}(t)=\frac{45}{2}n_{1}(t)

So, we have a relation between n i ( t ) i n_{i}(t) \ \forall i and b b .

finally, we need to calculate

j = 0 b 1 n j ( t ) . j p t = j = 1 b 1 n j ( t ) . j p t = ( b 1 ) b n 1 ( t ) 2 b t \frac{\sum_{j=0}^{b-1} n_{j}(t).j}{p^t}=\frac{\sum_{j=1}^{b-1} n_{j}(t).j}{p^t}=\frac{(b-1)bn_{1}(t)}{2b^t}

relation between n i ( t ) i n_{i}(t) \ \forall i and b b come useful now. We substitute n 1 ( t ) n_{1}(t) to have a fraction that depends only on b b . Then, t t is taken to be 3 3 and 7 7 , because of b 3 , b 7 b^3, b^7 , and the difference of their results is supposed to be equal to 2018. The rest was done numerically (the finale equation can be rewritten as a polynomial of order 7). There would be only one solution that can be the final answer and that would be 1009.5 1009.5 and I tried both 1009 1009 and 1010 1010 .

I got the formula

b ( t ) = b 1 2 t \varnothing_b(t) = \frac {b-1}{2} t

Where b ( t ) \varnothing_b(t) denotes the average digit sum of all integers less than b t b^t in base b b .

With this formula, it's easy to write an equation for the average up to b 3 b^3 and b 7 b^7 respectively and then set their difference equal to 2018

b 1 2 7 b 1 2 3 = 2018 2 ( b 1 ) = 2018 b = 1010 \begin{aligned} \frac {b-1}2 \cdot 7 - \frac {b-1}2 \cdot 3 & = 2018 \\ \Leftrightarrow 2(b-1) & = 2018 \\ \Leftrightarrow b & = 1010 \end{aligned}

So, I'm wondering how you used a method that didn't give exactly 1010.

Henry U - 2 years, 6 months ago

Log in to reply

why don't you post your solution? it seems you keep the community interested in working on the question by not posting a solution. Where do you find these problems anyways?

A Former Brilliant Member - 2 years, 6 months ago

Log in to reply

I watched a video by blackpenredpen on Youtube that is about binary numbers, and then I asked myself about the average number of powers of 2 needed to express some integer as their sum. This is the same question as the average digit sum. Then, I generalized this to any base.

Henry U - 2 years, 6 months ago

Log in to reply

@Henry U you are awesome man

A Former Brilliant Member - 2 years, 6 months ago

Log in to reply

@A Former Brilliant Member You too! You're number theory questions are really interesting and just the right difficulty for me.

Henry U - 2 years, 6 months ago

I will post my solution, but it takes a lot of writing and I haven't had the time so far.

Henry U - 2 years, 6 months ago

I have posted my solution now.

Henry U - 2 years, 5 months ago

David Vreken just posted a solution on the other problem where he also comes to this formula with a different approach than yours and mine.

Henry U - 2 years, 6 months ago

Log in to reply

David is a proper nerd. I am just a homeless drunk person :)

A Former Brilliant Member - 2 years, 6 months ago
Sourjyo Deb
Dec 25, 2018

Here let's take the Average digit sum of all the numbers from 0 to b n b^n be A ( n ) A(n) Therefore, we must find A ( n ) + 1 A(n)+1 . The average of first b n b^n integers is A ( n ) A(n) . The average of the next b n b^n integers is A ( n ) + 1 A(n)+1 as b ( n + 1 ) b^(n+1) place is 1. Similarly, next average is A(n)+2\ ) and so on until \(b^(n+1) place is b 1 b-1 . Hence, A ( n + 1 ) = i = 0 ( b 1 ) A ( n ) + i b A(n+1)=\frac{\sum_{i=0}^(b-1)A(n)+i}{b} = A ( n ) b + b ( b 1 ) 2 b ) =\frac{A(n)*b+\frac{b(b-1)}{2}}{b}) = A ( n ) + b ( b 1 ) 2 =A(n)+\frac{b(b-1)}{2}

A(0)=0.

Henry U
Dec 15, 2018

Let's try to find a pattern by first considering numbers in base 2:

decimal 0 10 0_{10} 1 10 1_{10} 2 10 2_{10} 3 10 3_{10} 4 10 4_{10} 5 10 5_{10} 6 10 6_{10} 7 10 7_{10} 8 10 8_{10} 9 10 9_{10} 1 0 10 10_{10} 1 1 10 11_{10} 1 2 10 12_{10} 1 3 10 13_{10} 1 4 10 14_{10} 1 5 10 15_{10} \ldots
binary 0 2 0_2 1 2 1_2 1 0 2 10_2 1 1 2 11_2 10 0 2 100_2 10 1 2 101_2 11 0 2 110_2 11 1 2 111_2 100 0 2 1000_2 100 1 2 1001_2 101 0 2 1010_2 101 1 2 1011_2 110 0 2 1100_2 110 1 2 1101_2 111 0 2 1110_2 111 1 2 1111_2 \ldots
digit sum 0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4 \ldots

The average digit sums of all integers less than 2 n 2^n , denoted by 2 ( n ) \varnothing_2(n) can now be calculated:

n n 0 1 2 3 4 5 \ldots
2 ( n ) \varnothing_2(n) 0 1 2 \frac 12 1 1 3 2 \frac 32 2 2 5 2 \frac 52 \ldots

It looks like, 2 ( n ) = 1 2 n \varnothing_2(n) = \frac 12 n . But why exactly is that?

Let's try to average the digit sums in a clever way by grouping them in groups of 2 = 2 1 2 = 2^1 and 4 = 2 2 4 = 2^2 respectively.

decimal 0 10 0_{10} 1 10 1_{10} 2 10 2_{10} 3 10 3_{10} 4 10 4_{10} 5 10 5_{10} 6 10 6_{10} 7 10 7_{10} 8 10 8_{10} 9 10 9_{10} 1 0 10 10_{10} 1 1 10 11_{10} 1 2 10 12_{10} 1 3 10 13_{10} 1 4 10 14_{10} 1 5 10 15_{10} \ldots
binary 0 2 0_2 1 2 1_2 1 0 2 10_2 1 1 2 11_2 10 0 2 100_2 10 1 2 101_2 11 0 2 110_2 11 1 2 111_2 100 0 2 1000_2 100 1 2 1001_2 101 0 2 1010_2 101 1 2 1011_2 110 0 2 1100_2 110 1 2 1101_2 111 0 2 1110_2 111 1 2 1111_2 \ldots
digit sum 0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4 \ldots
group average 1 2 \frac 12 2 2 \frac 22 3 2 \frac 32 4 2 \frac 42 5 2 \frac 52 6 2 \frac 62 7 2 \frac 72 9 2 \frac 92 \ldots
group average 1 2 2 3 \ldots

It looks like the average in every group just follows the same pattern as the digit sums. And this pattern will indeed continue. This is because the binary numbers from 2 n 2^n to 2 n + 1 1 2^{n+1}-1 are written almost like the numbers from 0 0 to 2 n 2^n , except for another digit 1 in the front, so their digit sum is just one more. Therefore, their average is 1 more than the average of the first half. The average of all numbers is the average of these two (since they both contain 2 n 2^n numbers ), so 1 2 \frac 12 more than the previous term. We can group the terms again and again until we get to a single number that is the average of all digit sums.

The formula for the average digit sum is indeed

2 ( n ) = 1 2 n \varnothing_2(n) = \frac 12 n


Let's try to do the same trick for base 3. This time, we can't group 4 numbers, but rather 3.

decimal 0 10 0_{10} 1 10 1_{10} 2 10 2_{10} 3 10 3_{10} 4 10 4_{10} 5 10 5_{10} 6 10 6_{10} 7 10 7_{10} 8 10 8_{10} 9 10 9_{10} 1 0 10 10_{10} 1 1 10 11_{10} 1 2 10 12_{10} 1 3 10 13_{10} 1 4 10 14_{10} 1 5 10 15_{10} 1 6 10 16_{10} 1 7 10 17_{10} \ldots
binary 0 2 0_2 1 2 1_2 2 3 2_3 1 0 3 10_3 1 1 3 11_3 1 2 3 12_3 2 0 3 20_3 2 1 3 21_3 2 2 3 22_3 10 0 3 100_3 10 1 3 101_3 10 2 3 102_3 11 0 3 110_3 11 1 3 111_3 11 2 3 112_3 12 0 3 120_3 12 1 3 121_3 12 2 3 122_3 \ldots
digit sum 0 1 2 1 2 3 2 3 4 1 2 3 2 3 4 3 4 5 \ldots
group average 1 2 3 2 3 4 \ldots

Again, the pattern repeats self-similarly, and we can write the formula

3 ( n ) = n \varnothing_3(n) = n


Now, it's time to generalize. What we've got so far is

2 ( n ) = 1 2 n \varnothing_2(n) = \frac 12 n

3 ( n ) = n = 2 2 n \varnothing_3(n) = n = \frac 22 n

The self-similar pattern will continue in all bases and the argument as explained for base 2 will also always work, so the general expreasion for b ( n ) \varnothing_b(n) is

b ( n ) = b 1 2 n \boxed{\varnothing_b(n) = \frac {b-1}2 n} .


After all this, we can plug in n = 3 n = 3 and n = 7 n=7 .

b ( 3 ) = b 1 2 3 \varnothing_b(3) = \frac {b-1}2 \cdot 3

b ( 7 ) = b 1 2 7 \varnothing_b(7) = \frac {b-1}2 \cdot 7

We are given that their difference is 2018, so we can set up the equation

b 1 2 7 b 1 2 3 = 2018 4 ( b 1 2 ) = 2018 2 ( b 1 ) = 2018 b = 1010 \begin{aligned} \frac {b-1}2 \cdot 7 - \frac {b-1}2 \cdot 3 & = 2018 \\ 4 \left( \frac {b-1}2 \right) & = 2018 \\ 2 (b-1) & = 2018 \\ b & = \boxed{1010} \end{aligned}

The average for a given power p p is p ( b 1 ) 2 \frac{p(b-1)}{2} . This is derived as the lower limit of a digit range is 0 0 and the upper limit is b 1 b-1 and you need the average of those limits as the digits add pairwise from each end of the range. The sum for multiple digit base- b b is the power times the single digit average. Solve 7 ( b 1 ) 2 3 ( b 1 ) 2 = 2018 \frac{7 (b-1)}{2}-\frac{3 (b-1)}{2}=2018 for b b . b b is 1010 1010 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...