0

What are the number of ways of picking (with replacement) $k$ integers from a successive set of integers from $1,2 ... n$ so they add to value n?

For example, say the set is $\{1,2,3,4\}$ then $n=4$ and for $k=1,2 ... n$ we have: $$\{1,1,1,1\}$$ $$\{2,1,1\}$$ $$\{2,2\}$$ $$\{3,1\} $$ $$\{4\}$$

Is there some formula for this or does it require an algorithm? Please provide these. Thanks.

Digitallis
  • 4,246
  • Your example is not clear: you show the five partitions of $n=4$ but your title question seems to ask for example how to find there are two partitions of $n=4$ into $k=2$ parts. – Henry May 12 '23 at 17:18
  • Henry, i don't say just k=2 anywhere?? – mszlazak May 12 '23 at 17:35

1 Answers1

1

@Henry makes the important point that your question appears to be asking for the number of partitions of $n$ into precisely $k$ parts. If we call this $p_k(n)$ then the relationship you require is given in

https://en.wikipedia.org/wiki/Triangle_of_partition_numbers

It is $$p_k(n)=p_{k-1}(n-1)+p_k(n-k).$$

For example, $p_2(2)=1$ since the only possibility is $1+1$ and $p_1(3)=1$ since the only possibility is just $3$.

Therefore $$p_2(4)=p_{1}(3)+p_2(2)=1+1=2.$$

Which of course is the same as you have already found.

user1172706
  • 2,791
  • The number of partitions of the number 4? I didn't ask that. It more like i have a pocket of coins, pennies, nickles, dimes and quarters, how many combinations of these will for say k=10 cents, k=25 cents or k=$1. – mszlazak May 12 '23 at 20:51
  • Your question specifically asks for $p_k(n)$. The use of $4$ is as an example. You can substitute whatever values you wish for $k$ and $n$. – user1172706 May 12 '23 at 21:12