Add together numbers to make final number?

329 Views Asked by At

I have this problem where I want to add some numbers together to make a final number. I ask how many ways are there to make this final number using exactly k numbers? Here is the condition:

(1) The numbers are in a consecutive sequence but with a number missing like 1,3,4 or 2,3,4,5.

(2) I want to have at least one of each number.

(3) I can use any number as many times like the permutation like 1,1,3,4,4.

I have this examples:

I want to make final number 12 with 1,3,4 in exactly 5 numbers. I can do only 1,1,3,3,4. And can do it 5!/(2!2!)=30 ways.

I want to make final number 21 with 1,2,3,4,6 in exactly 8 numbers. I can do only 1,1,2,2,2,3,4,6 or 1,1,1,2,3,3,4,6. I can do both in 8!/(2!3!)=3360 ways.

I think it involves partitions or combinations but I can't find a nice or any formula to do it. Is it possible to do this?

Thank you in advance. Sorry for the format I am new to maths exchange.

1

There are 1 best solutions below

1
On

Your question is similar to this one if not the sameFinding all possible combinations of numbers to reach a given sum

i wanted to comment but couldnt so i had to put it as an answer