Digit sum 0 to n

Write codeHard35 min

Your task

Return the sum of the decimal digits of every integer from 0 to n inclusive. For n=12 the answer is 0+1+2+...+9+1+(1+0)+(1+1)+(1+2) = 51. 0 <= n <= 10^12. Use an approach that does not iterate over every integer.

Examples

digit_sum_upto(n: int) -> int
Example 1
Inputdigit_sum_upto(12)
Output51