General formula for the $n^{\rm th}$ Smarandache number The $n^{\rm th}$ Smarandache number is defined as the concatenation of the first $n$ positive integers. The first few Smarandache numbers are thus the following: $1$, $12$, $123$, $\ldots$
For $n<9$, we can denote the $n^{\rm th}$ Smarandache number as:
$$
\sum_{k=1}^{n}10^{n-k}k = \frac{1}{81}(10^{n+1}-9n-10).
$$
Is there a general formula for any positive integer $n$?
 A: let $S_a$ be the $a^{th}$ smarandache number and $S_0=0$ $$\\$$
let $j\in\Bbb{N}\,|\,j$ is the smallest number that satisfies the inequality $10^j>n$.
$$S_n=S_{(10^{j-1}-1)}\cdot10^{j\cdot(n+1-10^{j-1})}+\frac{10^{j\cdot(n+2-10^{j-1})}-(10^j-1)(n+1-10^{j-1})-10^j}{(10^j-1)^2}+\frac{(10^{j-1}-1)(10^{j\cdot(n+1-10^j)}-1)}{10^j-1}$$
This formula is completed in $\lceil \log_{10}(n+1)\rceil$ steps.$$\\$$
For example $S_{101}$ is completed in three steps as shown below:
$$Step\,\,1:S_{101}=S_{99}\cdot10^{6}+\frac{10^9-(10^3-1)\cdot2-10^3}{999^2}+\frac{(10^2-1)(10^6-1)}{10^3-1}$$
$$Step\,\,2:S_{99}=S_{9}\cdot10^{180}+\frac{10^{182}-(10^2-1)\cdot90-10^2}{99^2}+\frac{(10^1-1)(10^{180}-1)}{10^2-1}$$
When n=9, $S_0$ is in the first term of the general expression so the first term equals zero. The last term of the general formula also equals zero when n=9. so,
 $$Step\,\,3:S_{9}=\frac{10^{10}-81-10}{9^2}$$
Note: There are a few super-scripts that are smaller than the others and difficult to read. These super-scripts are $j$ or $j-1$. 
