All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Monotonous integers (Posted on 2015-12-30) Difficulty: 3 of 5
For how many integers having between 1 and 10 digits (base 10) are all of their digits when read from left to right monotonically increasing? In other words, every digit is less than or equal to all of those to its right. For example, 244467889 is one of them, and 0 is another, but there are more.

See The Solution Submitted by Steve Herman    
Rating: 1.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution, starting out with analytic | Comment 3 of 9 |
How many 1-digit numbers satisfy the condition? Categorized by their last (in this case, only) digit, each has one satisfactory example:

last digit: 0  1  2  3  4  5  6  7  8  9 
number:     1  1  1  1  1  1  1  1  1  1
 

For 2-digit numbers, any 1-digit monotonous number ending with the same or lower digit can be extended by the one digit:

last digit: 0  1  2  3  4  5  6  7  8  9 
number:     1  2  3  4  5  6  7  8  9 10 

But these "2-digit numbers" include numbers that start with zero, and so the total of the numbers shown, 55, is really the total of 1- and 2-digit numbers that satisfy the criterion.


For 3-digit numbers, any 2-digit monotonous number ending with the same or lower digit can be extended by the one digit:

last digit: 0  1  2  3  4  5  6  7  8  9 
number:     1  3  6 10 15 21 28 36 45 55 

Again, of course, the total of these, 220, includes 1- and 2-digit monotonous numbers as well as the 3-digit variety.

Of course I'm tired of completing this by hand and then adding all the numbers.  I'll let the computer do it.

 max
digits                                                                 line total
  4     1     4    10    20    35    56    84   120   165   220             715
  5     1     5    15    35    70   126   210   330   495   715            2002
  6     1     6    21    56   126   252   462   792  1287  2002            5005
  7     1     7    28    84   210   462   924  1716  3003  5005           11440
  8     1     8    36   120   330   792  1716  3432  6435 11440           24310
  9     1     9    45   165   495  1287  3003  6435 12870 24310           48620
 10     1    10    55   220   715  2002  5005 11440 24310 48620           9
2378
 
So from 1- to 10-digit numbers, 92,378 are monotonous. 

DefDbl A-Z
Dim crlf$, grid(10, 10)


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For lastdig = 0 To 9
   grid(1, lastdig) = 1
 Next
 
 For numdigits = 2 To 10
   Text1.Text = Text1.Text & mform(numdigits, "##0")
   tot = 0
   For lastdig = 0 To 9
     t = 0
     For i = 0 To lastdig
       t = t + grid(numdigits - 1, i)
     Next
     grid(numdigits, lastdig) = t
     tot = tot + t
     Text1.Text = Text1.Text & mform(t, "#####0")
   Next
   Text1.Text = Text1.Text & "     " & mform(tot, "##########0") & crlf
 Next
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Note, the program also verifies the lines for 2- and 3-digit maximum lengths.

  Posted by Charlie on 2015-12-30 13:51:37
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information