Count the Number of Digits in an Integer

How to count the number of digits in an integer

Given a decimal number, continue dividing the number by ten until it reaches 0 and records the remainder at each step.

The resulting list of remainders is the equivalent place values of the Integer.


Input: 125

Output: 3

The illustration below explains the process of counting the digits in an integer.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy