A five digit positive integer is a mountain number if the first three digits are in strictly ascending order and the last three digits are in strictly descending order. For example, 46872 is a mountain number, but none of 43434, 54456 and 46766 is a mountain number.
Determine the probability that N is a mountain number, given that N is a positive integer chosen at random between 40000 and 99999 inclusively.
The peak (middle digit) of the mountain must be at least 6 as the first digit must be 4 or higher. The first portion of the number can start at 4, 5, 6 or 7. The number of possible first digits depends on the choice of the second digit:
peak second digit
digit 8 7 6 5 sum
     
9 4 3 2 1 10
8 3 2 1 6
7 2 1 3
6 1 1
As an example, when the second digit is a 7, there are 3 ways of choosing the first digit: 6, 5 or 4, so that 3 is the number that appears on the table above, under 7.
The last digit does not have the same restriction as the first (that is, needing to be 4 or higher), so the various fourth digits include more possibilities:
peak fourth digit
digit 8 7 6 5 4 3 2 1 sum
         
9 8 7 6 5 4 3 2 1 36
8 7 6 5 4 3 2 1 28
7 6 5 4 3 2 1 21
6 5 4 3 2 1 15
For example, when the fourth digit is 5, the last digit can be anything from 0 to 4, which is five possibilities.
For each of the four possible peak digits, you can combine any of the first/second digit pairs with any of the fourth/fifth digit pairs, so the total ways of producing a mountain number is:
10*36 + 6*28 + 3*21 + 1*15 = 606
This is out of a total of 99999  40000 + 1 = 60000, making the probability 606/60000 = 101/10000 = 0.0101.
Edited on April 7, 2010, 11:46 am

Posted by Charlie
on 20100407 11:44:17 