0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ This is the number of partitions of $M$ into at most $N$ parts. Look at en.wikipedia.org/wiki/… Wait, maybe not. Are the digits restricted to being $\le9?$ Then what I said would not be correct. It would be the number of partitions on $M$ in at most $N$ parts not exceeding $9$. $\endgroup$ – saulspatz Jul 24 '18 at 20:43
  • $\begingroup$ @packetpacket No, in a partition the summands are ordered. $\endgroup$ – saulspatz Jul 24 '18 at 20:47
  • $\begingroup$ @packetpacket No, 5-8-5 and 5-5-8 are the same partition You are thinking of compositions $\endgroup$ – saulspatz Jul 24 '18 at 20:54
  • $\begingroup$ @saulspatz My bad, I understand now. $\endgroup$ – packetpacket Jul 24 '18 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.