I was wondering if there is a formula for counting the number of positive integers solutions to the equation
\begin{equation}
a_1+a_2+\cdots+a_n=k,
\end{equation}
where $n\leq k$, $k\in \mathbb{N}$ and $n\geq 2$. The case when $n>k$ is impossible since the least positive value that can assume all the $a_i$ are equal to $1$, and adding these we get $n=k$, a contradiction, so it does not have any solutions, but what about the case when $k\geq n$? For example, I wish to find a general formula for counting the positive integers solutions to equations such as $a+b=5$ and $a+b+c+d=12$, that is, where the number of variables is less than the constant positive integer. Any help or hints given will be greatly appreciated.
Number of positive integer solutions to the equation $a_1+a_2+\cdots+a_n=k$, where $k\geq n$
combinatoricselementary-number-theory
Best Answer
Imagine we have placed $k$ balls in line, $$\text{ooooooo}\quad (k=7).$$ Positive-integer solutions of $a_1+\cdots+a_n=k$ correspond to partitions of the balls into $n$ parts. For example, $$\text{oo}|\text{o}|\text{oooo}\quad (n=3,k=7)$$ corresponds to the solution $(2,1,4)$ of the equation $a_1+a_2+a_3=7$. We can choose $n-1$ places to put $n-1$ walls, among the $k-1$ midpoints of two balls next to each other. Therefore, the number of solution is the binomial coefficient $$\begin{pmatrix}k-1\\n-1\end{pmatrix}.$$