ExamAdda Logo

Count Digits in a Number

Easy

Given a number n, return the count of digits in this number.

 

Example 1

Input

num = 1567

Output

4

Explanation

There are 4 digits in 1567, which are 1, 5, 6 and 7.

Example 2

Input

num = 99999

Output

5

Explanation

Number of digit in 99999 is 5.

Constraints

1 ≤ n ≤ 109

Hints:

Hint 1
Start with the straightforward approach, then optimize time or space if needed.

Author & Technical Reviewer

ExamAdda Technical Review Team

Technically reviewed by: ExamAdda Technical Review Team

Technical Reviewers, ExamAdda

Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.

Published

Jul 15, 2026

Last updated

Sep 15, 2026

Content Verification Methodology

Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output