Easy 0 solved 0% acceptance

Count Digits

Count the decimal digits of a positive integer.

Problem

Count how many decimal digits n has when written normally, without leading zeros.

Implement count_digits(n).

Input

n: A positive integer.

Output

Return the number of digits.

Constraints

1 ≤ n ≤ 10¹⁸

Examples

Example 1
Input:
n = 352

Expected output:
expected = 3
Input:
long long n = 352;

Expected output:
long long expected = 3;
Input:
long n = 352;

Expected output:
long expected = 3;

Explanation

352 has three digits.

Example 2
Input:
n = 7

Expected output:
expected = 1
Input:
long long n = 7;

Expected output:
long long expected = 1;
Input:
long n = 7;

Expected output:
long expected = 1;

Explanation

A single digit.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.