Made the numDigits function generic