Given number of digits required, $x$, find an $x$-digit number such that $f(1) = 1$, $f(2) = 12$, $f(3) = 123$, $f(4) = 1,234$, and so forth.
I'm banging my head against the wall trying to logically figure out what kind of formula would give such results. I'm using this for a web app I'm developing, and I'd rather find a formula than use a for
or while
loop.
Can anybody help? Thanks!
P.S.: Not sure if this will help, but so far I've got this:
$f(n) = \displaystyle\sum_{i=0}^{n-1} 10^i(n-i)$
But is there a formula that I could easily use in code (basic algebra, so summation notation)?