Skip to main content
8 of 8
added 29 characters in body
Karl Napf
  • 4.4k
  • 13
  • 31

Python 2, 78 70 68 64 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))
Karl Napf
  • 4.4k
  • 13
  • 31