Return the total number of times the digit 1 appears when you write all the numbers from 1 to n.
For n = 13 the answer is 6 (1, 10, 11 (two), 12, 13).
The starter code looks at the digits of every number. It is correct but too slow for large n.
Example 1
Input:
count_digit_one(13)
Output:
6
Example 2
Input:
count_digit_one(0)
Output:
0
0 <= n <= 9 * 10**15No results yet
Run your code to check it against the examples, or submit to run every test.