
sumOfDigits2
Given a positive integer n
, your task is to calculate the number of integers in the range [1, n]
that have the same sum of digits as n
.
Example
- For
n = 90
, the output should beSumOfDigits2(n) = 10
.
There are10
numbers in the range[1, 90]
whose digits sum up to9
:9
,18
,27
,36
,45
,54
,63
,72
,81
,90
.
Input/Output
-
[execution time limit] 0.5 seconds
-
[input] integer n
A positive integer.
Constraints:
1 ≤ n ≤ 109
. -
[output] integer
- The result.
Post Comment