Azim Premji University At Right Angles, November 2022 63
Student Corner
Definition.A mountain number is a (base ten) number with the following features (the references throughout are to its decimal digits):
(i) Its first digit and last digit are both 1.
(ii) Its digits increase up to a point and then start decreasing.
(iii) Two consecutive digits in the number cannot be the same.
Examples of mountain numbers:
1, 1431, 125631, 147851, 12345678987654321.
Examples of non-mountain numbers:
11, 1331, 14351, 23561, 12389, 235643, 1235461. Clearly, the smallest possible mountain number is 1, while the largest possible mountain number is
12345678987654321. The largest possible number of digits in a mountain number is 17. Also, there is no mountain number with exactly 2 digits.
In this article, we pose and answer the following two questions.
(1) What is the total number of mountain numbers with n digits, for 3≤n≤17?
(2) What is the total number of mountain numbers?
1
On Mountain Numbers
RAGHAV JEYAN PRABU
Keywords: Mountain number, peak value, combinatorial identity
64 Azim Premji University At Right Angles, November 2022
Let thepeak valueof a mountain number refer to its largest digit. Denote the peak value by z. We shall first try to find an expression for the total number of mountain numbers with n digits (where 3≤n≤17) and with a peak value of z.
A mountain number with a peak value of z has the following appearance:
1 . . . .
A=digits between 1 and z
z . . . .
B=digits between z and 1
1. (1)
Let A denote the string of digits between 1 and z; these occur in strictly increasing order. Let B denote the string of digits between z and 1; these occur in strictly decreasing order. The digits in A and B are all drawn from the set{2,3, . . . ,z−2,z−1}. Note that this set has(z−2)elements.
Let A have k elements; then B has n−3−k elements. The number of choices for the string A is
z−2Ck,
since after selection of the digits, there is just one way of arranging them. Similarly, the number of choices for the string B is
z−2Cn−3−k.
It follows that the total number of mountain numbers with n digits and with a peak value of z is
k
z−2Ck·z−2Cn−3−k, (2)
the summation being over an appropriate interval of values for k. (We do not need to worry too much about the precise interval because of the useful convention thataCb=0 if a<b.)
Now we recall the following well-known combinatorial identity: for fixed values of m,n,p,
k
mCk·nCp−k =m+nCp. (3)
(The identity is obtained by equating the coefficients of xpon the two sides of the equality (1+x)m·(1+x)n= (1+x)m+n.
We leave the details to the reader.) It follows that the total number of mountain numbers with n digits (for n≥3) and a peak value of z is
2z−4Cn−3. (4)
Hence the total number of mountain numbers with n digits (for n≥3) is
z
2z−4Cn−3. (5)
For the range of z in the summation, we must have 2z−4≥n−3, i.e., z≥ n+1
2 . (6)
Therefore, the summation is over⌈(n+1)/2⌉ ≤z≤ 9.
Azim Premji University At Right Angles, November 2022 65
Sample calculations.
• To count the mountain numbers with 3 digits, we put n=3; the required count is:
9
z=2
2z−4C0 =1+1+1+1+1+1+1+1= 8.
The 8 mountain numbers are obviously 121, 131, 141, …, 191.
• To count the mountain numbers with 4 digits, we put n=4; the required count is:
9
z=3
2z−4C1= 2+4+6+8+10+12+14=56.
• To count the mountain numbers with 6 digits, we put n=6; the required count is:
9
z=4
2z−4C3 =4C3+6C3+8C3+10C3+12C3+14C3= 784.
The individual counts are given in the following table:
n Total number of n-digit mountain numbers
1 1
3 8
4 56
5 252
6 784
7 1792
8 3108
9 4166
n Total number of n-digit mountain numbers
10 4352
11 3544
12 2232
13 1068
14 376
15 92
16 14
17 1
The total number of mountain numbers can be computed by adding all these individual counts:
1+8+56+252+784+1792+3108+4166+4352+3544+2232+1068+376+92+14+1
=21846.
Thus, there are 21846 mountain numbers altogether.
But there is a nicer way of getting the total number. Consider the mountain numbers with a peak value of z, having 3 or more digits. Between the leftmost 1 and z is an ascending string of any length, drawn from the set{2,3,4, . . . ,z−1}; there are 2z−2such strings (because set with k elements has 2ksubsets).
Similarly, between z and the rightmost 1 is a descending string of any length, drawn from the same set;
66 Azim Premji University At Right Angles, November 2022
there are 2z−2such strings. Therefore the total number of mountain numbers with the peak value of z is 2z−2·2z−2=4z−2. Hence the total count of mountain numbers having 3 or more digits is
9
z=2
4z−2 =1+4+42+· · ·+47
= 48−1
4−1 =21845.
Hence the total count of mountain numbers with all possible lengths is 21845+1= 21846.
References
1. MathEd (blog), “On Mountain Numbers” fromhttps://mathsedideas.blogspot.com/search/label/Mountain%20Numbers
RAGHAV JEYAN PRABU is a 13-year-old boy from Pune. He is studying in Dr. Kalmadi Shamarao High School, Baner. Raghav was one of the few who were selected for Epsilon India Math camp 2021; he is attending Ganit Manthan, a year-long program, in which problems are discussed in detail. His favourite subject is mathematics; he also enjoys physics and does coding in Python in his free time. He can be reached at [email protected].