Numbers with increasing digits

Find the sum of all whole numbers whose digits are strictly increasing.

Examples of such numbers are 5, 379, and 12345789

Some non-examples are 22, 102, and 123456798


The answer is 320214537.

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.

4 solutions

Kartik Sharma
Jun 20, 2018

Let's say the sum of all numbers with strictly increasing digits ending with n n be S n S_n .

If the number satisfies such a property, then, the the number excluding the ones' digit also satisfies that property. Thus,

S n = 10 k = 0 n 1 S k + ( No. of such numbers ) × n S_n = 10 \sum_{k=0}^{n-1} {S_k} + \left(\text{No. of such numbers} \right) \times n

Now, for no. of such numbers, we have the recurrence -

a n = 1 + a 1 + a 2 + a 3 + + a n 1 a_n = 1 + a_1 + a_2 + a_3 + \cdots + a_{n-1}

a n = 2 a n 1 , a 1 = 1 a_n = 2 a_{n-1}, a_1 = 1

a n = 2 n 1 a_n = 2^{n-1}

Thus, the sum recurrence becomes -

S n = 10 k = 0 n 1 S k + 2 n 1 n S_n = 10 \sum_{k=0}^{n-1} {S_k} + 2^{n-1} n

Now, we can use method of generating functions,

S ( z ) = n 0 S n = n 1 S n \displaystyle S(z) = \sum_{n \geq 0} S_n = \sum_{n \geq 1} S_n

S ( z ) = 10 z S ( z ) 1 z + z ( 1 2 z ) 2 S(z) = 10 z \frac {S(z)} {1-z} + \frac{z} {{(1 - 2z)}^2}

S ( z ) = z ( 1 z ) ( 1 11 z ) ( 1 2 z ) 2 S(z) = \frac{z(1-z)} {(1 - 11z){(1 - 2z)}^2}

S ( z ) = 10 81 ( 1 11 z ) 11 162 ( 1 2 z ) 1 18 ( 1 2 z ) 2 S(z) = \frac{10}{81 (1-11z)} - \frac{11}{162 (1 - 2z)} - \frac{1}{18 {(1 - 2z)}^2}

S n = 10 81 1 1 n 11 162 2 n 1 18 ( n + 1 ) 2 n S_n = \frac{10}{81} 11^n - \frac{11}{162} 2^n - \frac{1}{18} (n+1) 2^n

We have to find S 1 + S 2 + S 3 + + S 9 = S 10 10 × 2 9 10 = 320214537 \displaystyle S_1 + S_2 + S_3 + \cdots + S_9 = \frac{S_{10} - 10 \times 2^9} {10} = 320214537

Jeremy Galvagni
Jun 15, 2018
digit ones
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1

The one digit numbers sum to 45.

digit tens ones
1 8 0
2 7 1
3 6 2
4 5 3
5 4 4
6 3 5
7 2 6
8 1 7
9 0 8

The two digit numbers sum to 1440.

digit hundreds tens ones
1 28 0 0
2 21 7 0
3 15 12 1
4 10 15 3
5 6 16 6
6 3 15 10
7 1 12 15
8 0 7 21
9 0 0 28

The three digits numbers sum to 25830

digit 10^3 10^2 10^1 10^0
1 56 0 0 0
2 35 21 0 0
3 20 30 6 0
4 10 30 15 1
5 4 24 24 4
6 1 15 30 10
7 0 6 30 20
8 0 0 21 35
9 0 0 0 56

The four digit numbers sum to 310968

How do we know what number goes in a spot? For example, how do we know there are 30 four digit numbers with a 6 in the 10s place?

Consider _ _ 6 _. There are 10 three digit numbers that end in 6 and there are 3 two digit numbers that begin with 6. Just multiply the beginnings by the endings.

So we can keep building tables like the above, but I'll just give the totals.

five digits: 2592450

six digits: 14814720

seven digits: 55555515

eight digits: 123456780

nine digits: 123456789

total: 320214537

There are 511 ( 2 9 1 2^9-1 ) such numbers. Using the numbers from 1 to 511 (zero is not used as that would be a no digit number) as a binary mask to digits and add the numbers. This is a small programming loop. The sum is 320214537.

Michael Mendrin
Jun 18, 2018

Okay, I got the same answer as you did, 320214537.

Thanks. After solving this I realized I had no way of knowing if I was correct!

Jeremy Galvagni - 2 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...