An Ascending Number
has been defined by the following 2 properties:
- The number has at least 2 digits.
- All digits of the number are in strictly ascending order, in base 10.
For completeness, let's also add: no leading zeros or duplicate digits.
For what value of N is the probability that a randomly chosen N-digit number is also an ascending number closest to .01, i.e. a 1% chance?
For this value of N, what is the exact probability the random number N digits long is ascending?
The number of possible random n-digit natural numbers is
To be ascending with no leading zeros means there are no zeros at all. As a result n can be no higher than 9 as duplicates are not allowed.
The choice of what digits are included in the strictly ascending number determines what that number is, as they must be arranged in order. So the cardinality of that set of numbers is C(9,n).
The required probability is therefore
C(9,n) / (9*10^(n-1))
The probabilities are:
The closest probability to 0.01 is for n=4:
126 / 9000 = 7/500 = .014
The above assumes the random number has no leading zeros but is allowed to have duplicate digits, as that rule applies only to the ascending number, making it strictly ascending.
5 open "probasn.txt" for output as #2
10 for N=2 to 9
20 print N,combi(9,N)/(9*10^(N-1))
30 print #2,N,combi(9,N)/(9*10^(N-1))
110 close #2
Posted by Charlie
on 2020-03-16 15:08:07