Find the least positive integer $n$ such that $S(n)S(n + 2) = 2022$, where $S(n)$ is the sum of the digits of $n$. I was doing my math homework and I came across this problem:

Find the least positive integer $n$ such that $S(n)S(n + 2) = 2022$, where $S(n)$ is the sum of the digits of $n$.

I tried letting $S(n)=2022,$ and this is what I got:
$S(n)=2022,$ Thus $S(n+2)=1 \Rightarrow n+2=10^k.$
And $n=10^k-2 \Rightarrow S(n)=9k-1 \Rightarrow 9k=2023.$
But then $k$ is not a natural number so I don't know what to do now. Can I have help? Thanks!
 A: Partial answer:
As mentioned above, there are only four factorizations of 2022 into two factors:

*

*$1 \cdot 2022$

*$2 \cdot 1011$

*$3 \cdot 674$

*$6 \cdot 337$.

That limits your search a lot.
We can eliminate the first case ($1 \cdot 2022$) as follows:
For the sum of digits to be $1$, the number $n$ must be $1, 10, 100$, $\ldots$, that is, $n = 10^k$ (or $n-2 = 10^k$) for $k \in \mathbb{Z}$ and $k \geq 0$.
That means the other factor must have the sum of its digits be 2022.  There are two cases here, either the other number is a) $10^k + 2$ or b) $10^k - 2$ (according to the problem statement).  Case a) will always have the sum of digits as $3$, and hence cannot solve the problem.
Case b) admits numbers of the form $8$, $98$, $998$, $\ldots$.  The sum of such digits is $9 r + 8$, where $r = k-2$ is an integer.  But $9 r + 8$ can never equal 2022.  (Easy to check.)  So case b) cannot solve the problem.
Hence we can eliminate the $1 \cdot 2022$ cases.
We can thus limit our search to cases where one of the numbers has a sum of digits equal 2, or 3 or 6.
We can also eliminate the second case ($2 \cdot 1011$) as follows:
This is a vast reduction in the search space.  Consider the sum of digits = 2.  Either the number is $2 \cdot 10^k$ or $10^{r_1} + 10^{r_2}$ for $\{ r_1, r_2 \} \in \mathbb{Z}$.  Here too, we know that the other number cannot be of the form $10^{r_1} + 10^{r_2} + 2$, as its sum of digits will always be $4$ (for $r_2 \neq 0$).
Thus we need search $10^{r_1} + 10^{r_2} - 2$ for sum of digits = 1011.  All numbers of this form have sum of digit = $9 k$.  (Easy to check.). But $9 k \neq 1011$ for $k \in \mathbb{Z}$.  So we can eliminate the second major case, above.
Hope this helps.
