Python 2, 78 70 68 6464 63 bytes
Actually basing on the idea of Destructible Watermelon makes it even smaller (using input
is even better)(filling the string backward saves 4 bytes)(no ()
at while
):
n,s=input(),''
l=len(`n`)
while( n):s=`n`.zfill(l)+s;n-=l
print s
Here is the old 70 byte approach (Saving 8 bytes by using backquotes instead of str
and dropping the square brackets around generator thanks to Dennis):
def f(n):l=len(`n`);print"".join(`x`.zfill(l)for x in range(l,n+l,l))