In how many ways i can write 12 as an ordered sum of integers where
the smallest of that integers is 2? for example 2+10 ; 10+2 ; 2+5+2+3 ; 5+2+2+3;
2+2+2+2+2+2;2+4+6; and many more
[Math] In how many ways i can write 12
combinatoricsinteger-partitions
Related Solutions
As Brian M. Scott mentions, these are partitions of $n$. However, allowing $0$ into the mix, makes them different to the usual definition of a partition (which assumes non-zero parts). However, this can be adjusted for by taking partitions of $n+k$ into $k$ non-zero parts (and subtracting $1$ from each part).
If $p(k,n)$ is the number of partitions of $n$ into $k$ non-zero parts, then $p(k,n)$ satisfies the recurrence relation \begin{align} p(k,n) &= 0 & \text{if } k>n \\ p(k,n) &= 1 & \text{if } k=n \\ p(k,n) &= p(k+1,n)+p(k,n-k) & \text{otherwise}. \\ \end{align} (this recurrence is explained on Wikipedia). Note: in the above case, remember to change $n$ to $n+k$. This gives a (moderately efficient) method for computing $p(k,n)$.
The number of partitions of $n$ into $k$ parts in $\{0,1,\ldots,n\}$ can be computed in GAP using:
NrPartitions(n+k,k);
Some small values are listed below:
$$\begin{array}{c|ccccccccccccccc} & k=1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 \\ \hline 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 2 & 1 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 \\ 3 & 1 & 2 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 \\ 4 & 1 & 3 & 4 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 \\ 5 & 1 & 3 & 5 & 6 & 7 & 7 & 7 & 7 & 7 & 7 & 7 & 7 & 7 & 7 & 7 \\ 6 & 1 & 4 & 7 & 9 & 10 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 & 11 \\ 7 & 1 & 4 & 8 & 11 & 13 & 14 & 15 & 15 & 15 & 15 & 15 & 15 & 15 & 15 & 15 \\ 8 & 1 & 5 & 10 & 15 & 18 & 20 & 21 & 22 & 22 & 22 & 22 & 22 & 22 & 22 & 22 \\ 9 & 1 & 5 & 12 & 18 & 23 & 26 & 28 & 29 & 30 & 30 & 30 & 30 & 30 & 30 & 30 \\ 10 & 1 & 6 & 14 & 23 & 30 & 35 & 38 & 40 & 41 & 42 & 42 & 42 & 42 & 42 & 42 \\ 11 & 1 & 6 & 16 & 27 & 37 & 44 & 49 & 52 & 54 & 55 & 56 & 56 & 56 & 56 & 56 \\ 12 & 1 & 7 & 19 & 34 & 47 & 58 & 65 & 70 & 73 & 75 & 76 & 77 & 77 & 77 & 77 \\ 13 & 1 & 7 & 21 & 39 & 57 & 71 & 82 & 89 & 94 & 97 & 99 & 100 & 101 & 101 & 101 \\ 14 & 1 & 8 & 24 & 47 & 70 & 90 & 105 & 116 & 123 & 128 & 131 & 133 & 134 & 135 & 135 \\ 15 & 1 & 8 & 27 & 54 & 84 & 110 & 131 & 146 & 157 & 164 & 169 & 172 & 174 & 175 & 176 \\ \hline \end{array}$$
If you want a list of the possible partitions, then use:
RestrictedPartitions(n,[0..n],k);
Comment: In the latest version of GAP,
NrRestrictedPartitions(n,[0..n],k);
does not seem to work properly here, since it does not match
Size(RestrictedPartitions(n,[0..n],k));
when $k>n$. I emailed the support team about this, and they said that NrRestrictedPartitions
and RestrictedPartitions
are only intended to be valid for sets of positive integers. (I still think the above is a bug, but let's let that slide.) This means that NrPartitions(n+k,k);
is the technically correct choice, and, strictly speaking, we shouldn't use RestrictedPartitions(n,[0..n],k);
, but judging from the source code, it will work as expected.
These are called integer partitions, and there are a lot of fun combinatorics that goes along with them. If we let $p(n)$ denote the number of integer partitions of $n$, the generating function is given by
$$ \sum_{n=0}^{\infty} p(n) x^n = \prod_{j=1}^{\infty}\frac{1}{1-x^j} $$
it's not too hard to convince yourself this is correct: the product on the right can be seen as
$$(1+x^{1\cdot1}+x^{2\cdot1}+x^{3 \cdot 1}+\dots)(1+x^{1\cdot2}+x^{2\cdot2}+x^{3\cdot 2}+\dots)(1+x^{1\cdot3}+x^{2\cdot3}+x^{3\cdot3}+\dots)\dots$$
so for example if we look at how one might get $x^5$:
- $x^{1\cdot5} \iff 5$
- $x^{1\cdot4} x^{1\cdot1} \iff 4 + 1$
- $ x^{1\cdot3}x^{1\cdot2} \iff 3 + 2$
- $ x^{1\cdot3}x^{2\cdot1} \iff 3 + 1 + 1$
- $ x^{2\cdot2}x^{1\cdot1} \iff 2 + 2 + 1$
- $ x^{1\cdot2}x^{3\cdot1} \iff 2 + 1 + 1 + 1$
- $ x^{5\cdot1} \iff 1 +1+1+ 1 + 1$
and so $p(5) = 7$, as you enumerated.
Unfortunately there's no nice formula for this, but asymptotically we have
$$p(n) \sim \frac{e^{\sqrt n \,c}}{4\sqrt 3 \,n},$$
where $ c = \sqrt \frac{2}{3} \pi$. This is harder to prove, but I believe it is due to Hardy and Ramanujan.
Here is the most straightforward proof I could find, though it uses some results from Complex Analysis.
This is a proof using only real analysis, but the result is slightly weaker.
Best Answer
There are $89$ ways (and $89$ is the $11$th Fibonacci number).
You're looking for "restricted compositions" of $12$ (the restriction being that each part is at least $2$).
In Sage (doc):
The number for general $n$ in place of $12$ would be interesting to calculate. Using Sage again:
Searching for that on OEIS gives A212804 as the sequence.
This of course is the Fibonacci sequence with an additional "1" at the beginning.
Now it would be interesting to prove that it is so for general $n$. This is easy now that we know what to prove. Let's call compositions with each part at least $2$ as "good" compositions. Let $C_n$ be the number of "good" compositions of $n$. Any such "good" composition either begins with $2$ or with a number greater than 2:
If it starts with $2$, then it can be got by prepending a $2$ to a "good" composition of $n-2$ (and there are $C_{n-2}$ of them)
If it starts with a number greater than $2$, then it can be got by taking a "good" composition of $n-1$ (there are $C_{n-1}$ of them) and incrementing the first element by one.
So $C_n = C_{n-2} + C_{n-1}$, which along with the initial conditions $C_0 = 1$ and $C_1 = 0$, proves what we wanted to prove.