Maths Olympiad Prep

Library / USAJMO /3 of 29

USAJMO

Combinatorics Difficulty 6.2 National Olympiad Find the answer

For each positive integer nn , find the number of nn -digit positive integers that satisfy both of the following conditions:
∙\bullet no two consecutive digits are equal, and
∙\bullet the last digit is a prime.

A number or a short expression. Fractions can be typed as 3/2, and spacing doesn't matter.

Solution

The answer is 25(9n+(−1)n+1)\boxed{\frac{2}{5}\left(9^n+(-1)^{n+1}\right)} .
Suppose ana_n denotes the number of nn -digit numbers that satisfy the condition. We claim an=4⋅9n−1−an−1a_n=4\cdot 9^{n-1}-a_{n-1} , with a1=4a_1=4 . Proof.\textit{Proof.} It is trivial to show that a1=4a_1=4 . Now, we can do casework on whether or not the tens digit of the nn -digit integer is prime. If the tens digit is prime, we can choose the digits before the units digit in an−1a_{n-1} ways and choose the units digit in 33 ways, since it must be prime and not equal to the tens digit. Therefore, there are 3an−13a_{n-1} ways in this case.
If the tens digit is not prime, we can use complementary counting. First, we consider the number of (n−1)(n-1) -digit integers that do not have consecutive digits. There are 99 ways to choose the first digit and 99 ways to choose the remaining digits. Thus, there are 9n−19^{n-1} integers that satisfy this. Therefore, the number of those (n−1)(n-1) -digit integers whose units digit is not prime is 9n−1−an−19^{n-1}-a_{n-1} . It is easy to see that there are 44 ways to choose the units digit, so there are 4(9n−1−an−1)4\left(9^{n-1}-a_{n-1}\right) numbers in this case. It follows that an=3an−1+4(9n−1−an−1)=4⋅9n−1−an−1,a_n=3a_{n-1}+4\left(9^{n-1}-a_{n-1}\right)=4\cdot 9^{n-1}-a_{n-1}, and our claim has been proven.
Then, we can use induction to show that an=25(9n+(−1)n+1)a_n=\frac{2}{5}\left(9^n+(-1)^{n+1}\right) . It is easy to see that our base case is true, as a1=4a_1=4 . Then, an+1=4⋅9n−an=4⋅9n−25(9n+(−1)n+1)=4⋅9n−25⋅9n−25(−1)n+1,a_{n+1}=4\cdot 9^n-a_n=4\cdot 9^n-\frac{2}{5}\left(9^n+(-1)^{n+1}\right)=4\cdot 9^n-\frac{2}{5}\cdot 9^n-\frac{2}{5}(-1)^{n+1}, which is equal to an+1=(4−25)⋅9n−25⋅(−1)n+2(−1)=185⋅9n+25⋅(−1)n+2=25(9n+1+(−1)n+2),a_{n+1}=\left(4-\frac{2}{5}\right)\cdot 9^n-\frac{2}{5}\cdot\frac{(-1)^{n+2}}{(-1)}=\frac{18}{5}\cdot 9^n+\frac{2}{5}\cdot(-1)^{n+2}=\frac{2}{5}\left(9^{n+1}+(-1)^{n+2}\right), as desired. □\square
Solution by TheUltimate123.

Want a route through all this instead of an archive? The track puts 2,604 problems in a working order, from Junior Challenge level to the IMO shortlist.

Source: Omni-MATH, licensed Apache-2.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.