The following function is used when you need to format a number to be 2 digits regardless of the value. For example the number in question is "1" but you wish it to be displayed as "01" to maintain layout or number formatting. This is commonly used when formatting a time or date. Adding a leading zero is sometimes referred to as "zero padding".
This example will format the number into 3 digits, for example "7" becomes "007"
And this one formats to 4 digits.
Hopefully from these 2 examples you should be able to extrapolate the script to as many digits as you require.