How Many Digits? (Baby Steps)

Count the digits of a number n. For example 5 has 1 digit, 42 has 2, and 1000 has 4. The number 0 has 1 digit.

Input: One integer n (0 to 1000000000).

Output: One integer: how many digits n has.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Dividing by 10 removes the last digit: 1234 / 10 is 123.

More Baby Steps practice