refactoring: CountDigits replaced by lambda that calls itself.