What's that number in Shortlex? Most computers store integers in binary, but output them in decimal. However, decimal is just one representation, we just happen to find it convenient.

This challenge is to write some code to output an integer value in shortlex decimal.

What's that?
http://en.wikipedia.org/wiki/Shortlex_order

Shortlex takes the length of the sequence of digits as the primary signifier of value. The sequence, starting from an empty string representing zero, is...    

ε,0,1,...,8,9,00,01,...98,99,000,001,...,998,999,0000,...


(Think of Excel columns, but using only the decimal digits.)

Write a program or function that accepts an integer and returns a string corresponding to the shortlex-decimal representation of that integer as described above.

Test values:

0 → ""  (Empty string)
1 → "0"
10 → "9"
11 → "00"
42 → "31"
100 → "89"
800 → "689"
1060 → "949"
10270 → "9159"
100501 → "89390"
JavaScript (ES6) 42 74
n=&gt;(n-~(n+'').replace(/./g,8)+'').slice(1)

Test in FireFox console
;[0,1,10,11,42,100,800,1060,10270,100501]
.forEach(x =&gt; console.log(x +&quot; -&gt; '&quot; + S(x) + &quot;'&quot;))

Output
0 -&gt; ''
1 -&gt; '0'
10 -&gt; '9'
11 -&gt; '00'
42 -&gt; '31'
100 -&gt; '89'
800 -&gt; '689'
1060 -&gt; '949'
10270 -&gt; '9159'
100501 -&gt; '89390'

How did I think of this?
Given a fixed number of digits, the output sequence is simply ascending, so there is a fixed delta between input and output. Have a look:
  1..10 -&gt; 0..9 (delta -1)
 11..110 -&gt; 00..99 (delta -11)
111..1110 -&gt; 000..999 (delta -111) mmm there's a pattern here...

But the leading 0s are difficult to manage, so I have a standard trick, add a first digit and work modulo (that is, cut the first digit in output). Then -1-&gt; +9, -11 -&gt; +89, -111 -&gt; +889 and so on. 
Last step: I don't care what the first digit is, so there is no need to check if the iinput number is &lt; or &gt; than 111... (honestly I found this by trial and error)
Test


var F=
n=&gt;(n-~(n+'').replace(/./g,8)+'').slice(1)

function update()
{
  var i=+I.value
  O.textContent = F(i)
}


update()
&lt;input id=I value=99 type=number oninput='update()'&gt;&lt;pre id=O&gt;&lt;/pre&gt;