This is pretty straight forward:
> sprintf("%013d",150025901)
[1] "0000150025901"
> sprintf("%013d",8150025901)
Error in sprintf("%013d", 8150025901) :
invalid format '%013d'; use format %f, %e, %g or %a for numeric objects
ultimately I need to use this on a 12 digit number, but I just removed digits until sprintf would stop returning that error.