Sum of digits of all numbers from 1 to N
Java
Medium
loops
Task «Sum of digits of all numbers from 1 to N»
Write a program that calculates the sum of digits of all numbers from 1 to N inclusive. For example, for N=11, the sum of digits is 1+2+3+4+5+6+7+8+9+1+0+1+1 = 38. Constraints: 1 ≤ N ≤ 10^6.
Input Format
The input is a single integer N (1 ≤ N ≤ 10^6).
Output Format
Output a single integer — the sum of digits of all numbers from 1 to N inclusive.
Examples
Example 1
INPUT
1
OUTPUT
1
Example 2
INPUT
10 20
OUTPUT
NO
Example 3
INPUT
9
OUTPUT
45
main.java