Number of ways to form distinctive number given sum of digits

50 Views Asked by At

We are given sum of digits M and maximum number of decimal places N.
We have to find the count of number that can be formed such the the sum of digits is M and the consecutive digit of the number should not be less than the previous digit for example:-

  • If M = 5 and N = 2 Possible numbers that can be formed are:- 05,14,23
    Hence count=3

  • If M = 3 and N = 3 Possible numbers that can be formed are:- 003,012,111
    Hence count=3

  • If M = 6 and N = 3 Possible numbers that can be formed are:- 006,015,024,033,114,123,222
    Hence count=7