For a positive integer $n$, let $S(n)$ denote its digit sum. Find all positive integers $M$ such that for every positive integer $k$ not exceeding $M$, we have $S(M k)=S(M)$.
We prove that except for the trivial case $M=1$, the condition holds if and only if $M=10^{n}-1$, such that for every positive integer $k$ not exceeding $M$,
$$
S(M k)=S(M).
$$

When $M=10^{n}-1$, for $2 \leqslant k \leqslant M, k M=(k-1) \cdot 10^{n}+\left(10^{n}-1\right)-(k-1)$, $S(k M)=S\left((k-1) \cdot 10^{n}\right)+S\left(\left(10^{n}-1\right)-(k-1)\right)=S(k-1)+(9 n-S(k-1))=$ $9 n=S(M)$.
Conversely, if (1) holds. Suppose $M$ has $n$ digits, with the leading digit being $d$, then
$$
M=d \times 10^{n-1}+m, S(M)=d+S(m).
$$

Take $k=10^{n-1}+1$, then $k \leqslant M$ (since $M$ cannot equal $10^{n-1}$, otherwise $S(2 M)=2>S(M)$).
$$
\begin{array}{c}
k M=10^{n-1} \cdot M+M=m+10^{n-1}(d+M), \\
S(k M)=S(m)+S(d+M), \text{ thus } d=S(d+M).
\end{array}
$$

If $d < 9$, then $S(d+M) > d$. Set $d=9$. If $M$ has a digit less than 9, then $S(M+d)>d$ still holds. Therefore, all digits of $M$ must be 9, i.e., $M=10^{n}-1$.