Utility function that returns the count of numbers written down when starting from n
function getCount ( $ n ) { $ count = 1 ; while ( $ n != 0 ) { $ leadDigit = firstDigit ( $ n ) ; $ n -= $ leadDigit ; $ count ++ ; } return $ count ; }