Define glueing of positive integers as writing their base ten representations one after another and interpreting the result as the base ten representation of a single positive integer. Find all positive integers $k$ for which there exists an integer $N_k$ with the following property: for all $n \ge N_k$, we can glue the numbers $1,2,\dots,n$ in some order so that the result is a number divisible by $k$. Remark. The base ten representation of a positive integer never starts with zero. Example. Glueing $15, 14, 7$ in this order makes $15147$.
Problem
Source: MEMO 2024 T7
Tags: number theory, number theory proposed, Digits
11.11.2024 20:57
Tintarn wrote: Define glueing of positive integers as writing their base ten representations one after another and interpreting the result as the base ten representation of a single positive integer. Find all positive integers $k$ for which there exists an integer $N_k$ with the following property: for all $n \ge N_k$, we can glue the numbers $1,2,\dots,n$ in some order so that the result is a number divisible by $k$. Remark. The base ten representation of a positive integer never starts with zero. Example. Glueing $15, 14, 7$ in this order makes $15147$. If $3\mid k$ and $n\equiv1\pmod{3}$, the digits sum of the number $1,2,\ldots,n$ glued together is the sum of digits sums of $1,2,\ldots,n$. This is congruent to $1+2+\ldots+n\equiv1\pmod{3}$. So all numbers with $3\mid k$ do not have the desired property. We claim that every number with $3\nmid k$ has the desired property. Let $k=2^a5^bk'$ with $2,3,5\nmid k'$. For $n\geq 10^{a+b}$ we can put $10^{a+b}$ at the end. This ensures that the numbers glued together are divisible by $2^a5^b$. Every prime divisor $p$ satisfies $10\not\equiv0,1\pmod{p}$. So there is a sufficiently large $l,m\geq0$ and numbers $a_1,\ldots,a_{k'}$ with $m$ digits each, $b_1,\ldots,b_{k'}$ with $l$ digits each such that $10^m\equiv10\pmod{k'},10^{l+m}\equiv1\pmod{k'},a_1\equiv\ldots\equiv a_k\equiv1\pmod{k'}$ and $b_1\equiv\ldots\equiv b_k\equiv0\pmod{k'}$. Then $a_i,b_i$ glued together are congruent to $10^{l}\equiv10^{-1}\pmod{k'}$ and $b_i,a_i$ glued together are congruent to $1\pmod{k'}$. If we move both numbers $(i-1)(l+m)+(a+b+1)$ positions to the right, these numbers get multiplied by $10^{(i-1)(l+m)+(a+b+1)}\equiv10^{a+b+1}\pmod{k'}$. So if we put $b_{k'},a_{k'},\ldots,b_1,a_1,10^{a+b}$ at the end switch $d$ of the pairs $(b_i,a_i)$ to $(a_i,b_i)$ this last $2k'+1$ numbers glue to a number congruent to $d\cdot10^{a+b}+(k'-d)\cdot10^{a+b+1}\equiv-9\cdot10^{a+b}\cdot d\pmod{k'}$. Since $9\cdot10^{a+b}$ is coprime to $k'$, this can take any residue class $\pmod{k'}$. So for sufficiently large $n$, glue all numbers $\leq n$ expect the $2k'+1$ from before together and add the $2k'+1$ number at the end in a way that makes the result divisible by $10^{a+b},k'$ and thus $k$.