Loading Now

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 be SumOfDigits2(n) = 10.

    There are 10 numbers in the range [1, 90] whose digits sum up to 99182736455463728190.

Input/Output

  • [execution time limit] 0.5 seconds

  • [input] integer n

    A positive integer.

    Constraints:

    1 ≤ n ≤ 109.

  • [output] integer

    • The result.

Post Comment

Contact