Find the smallest number $n$ such that $n$ is divisible by 23, $n+1$ is divisible by 29, and both $n$ and $n+1$ contain only the digits '1' and '2'.

## Solution

Probably the best way to go at this is to generate the list of all five-digit numbers whose digits are either 1's or 2's. There are 32 such numbers (why?). The smallest is 11111 and the largest is 22222. Once you have the list, perhaps on a spreadsheet, start dividing each by 23 and by 29, and hunt for the numbers that are one apart.

The answer is $n = 12121 = 23 \cdot 527$, and $n+ 1 = 12122 = 29 \cdot 418.$