394. Count Commas in Range

EasyMath

You are given an integer n. Return the total number of commas used when writing all integers from [1, n] (inclusive) in standard number formatting. In standard formatting: - A comma is inserted after every three digits from the right. - Numbers with fewer than 4 digits contain no commas.

Examples

Input: 1002

Output: 3

Explanation: "1,000", "1,001", and "1,002" each contain one comma → 3 total.

Constraints

  • 1 <= n <= 10^5
Loading...

Run checks all cases above. Submit evaluates all test cases.