In how many ways I can write a number $n$ as sum of $4$ numbers?

The precise problem is in how many ways I can write a number $n$ as sum of $4$ numbers say $a,b,c,d$ where $a \leq b \leq c \leq d$.

I know about Jacobi’s $4$ square problem which is number of ways to write a number in form of sum of $4$ squares number. There is a direct formula for it. Is there a direct formula for this problem too?

Edit: All the numbers are positive integers greater than $0$.
Example: For $5$ there is only one way $1,1,1,2$.

Solutions Collecting From Web of "In how many ways I can write a number $n$ as sum of $4$ numbers?"

Note that this problem is equivalent to the problem of partitioning $n$ into $4$ parts.

In number theory, a partition is one in which the order of the parts is unimportant. Under these conditions, we are under the illusion that the order is important, however we can only order any given combination of $4$ parts in $1$ way. Thus, the order is unimportant.

There is a well known recurrence for $p(n,k)$, the number of partitions of $n$ into $k$ parts. It is given by
$$p(n,k) = k\cdotp(n-1,k) + p(n-1,k-1).$$
Your question is only concerned with the case of $k=4$.

You can write a generating function for this problem. Let me generalize your question. For $n\in\mathbb{N}_0$ and $k\in\mathbb{N}$, let $a_k^n$ be the number of ways to write $n$ as a sum $x_1+x_2+\ldots+x_k$ of integers $x_1,x_2,\ldots,x_k$ such that $0\leq x_1\leq x_2 \leq \ldots \leq x_k$.

Observe that this is the same problem as writing $n$ in the form $y_1+2y_2+\ldots+ky_k$, where $y_1,y_2,\ldots,y_k\in\mathbb{N}_0$. To see this, we take $y_k:=x_1$ and $y_{k-i}:=x_{i+1}-x_i$ for $i=1,2,\ldots,k-1$. Hence, the generating function $f_k(t):=\sum_{n=0}^\infty\,a_n^k\,t^k$ is given by $$f_k(t)=\prod_{i=1}^k\left(\sum_{r=0}^\infty\,t^{ir}\right)=\prod_{i=1}^k\,\left(\frac{1}{1-t^i}\right)=\frac{1}{\prod_{i=1}^k\,\left(1-t^i\right)}\,.$$

For example, $f_4(t)=1+t+2t^2+3t^3+5t^4+6t^5+9t^6+11t^7+\ldots$. One not-so-nice recursive formula for $a^n_k$’s is $a^n_k=1+\sum_{j=1}^{k-1}\,\sum_{r=1}^{\left\lfloor n/(j+1)\right\rfloor}a_j^{n-r(j+1)}=a_k^{n-k}+a_{k-1}^{n}$ for $n\in\mathbb{N}_0$ and for integers $k>1$, where $a^n_1=1$ for every $n\in\mathbb{N}_0$ and $a^0_k=1$ for every $k\in\mathbb{N}$. However, I think having the generating function is a sufficient answer. If you want the number of solutions in which $x_1 \geq 1$, then it is easily seen that the answer for each $n$ is $a^{n-k}_k$ if $n \geq k$, and $0$ if $n<k$.