Unique ways to write $n$ as sum of three distinct nonnegative integers up to the order of the summands How many ways are there to express a natural number, $n$, as the sum of three whole numbers, $a,b,c$, where $a,b,c$ are allowed to be 0 but are unique?
For example: $n=9$ there are only seven ways: $1+2+6, 1+3+5, 2+3+4, 0+1+8, 0+2+7, 0+3+6, 0+4+5$.
PS: Looking at some previous [answers]Generating function for counting compositions of $n$, I learnt this "thing" is known as partitions of $n$. But I did not find an answer that includes 0 and does not allow repetitions. Number theory is not my area, and all I would like to know is if some analytical formula can determine this.

Suppose $S$ is the set of ordered triplets $\{x,y,z\}$ such that $x+y+z=n$. As you know the size of $S$ is $n+2 \choose 2$. There are three types of triplets in $S$.

*

*$x,y,z$ are all distinct.

*Exactly two of $x,y,z$ are the same.

*$x=y=z$.

Let $t_1,t_2,t_3$ be the number of triplets of type 1, 2 and 3 respectively. So, $t_1+t_2+t_3=|S|$. $t_3=1$ if $n$ is divisible by 3 otherwise $t_3$ = 0. The number of pairs $\{u,v\}$ such that $2u+v=n$ is $ \lfloor{\frac{n}{2}} \rfloor - t_3 + 1 $. Each such pair contributes exactly 3 ordered triplets $\{u,u,v\},\{u,v,u\},\{v,u,u\}$ in  $S$. Hence, $t_2= 3(\lfloor{\frac{n}{2}} \rfloor - t_3 + 1)$.  You are looking for the number of unordered triplets $\{a,b,c\}$ such that $a+b+c=n$. This count is exactly equal to $t_1/6$ as each such unordered triplet $\{a,b,c\}$ contributes 6 ordered triplets of type 1 in $S$. So, the count is $$\frac{|S|-t_2-t_3}{6} = \frac{\binom{n+2}{2}-3(\lfloor{\frac{n}{2}} \rfloor - t_3 + 1)-t_3}{6}= \frac{\binom{n+2}{2}-3(\lfloor{\frac{n}{2}} \rfloor + 1)+2t_3}{6}.$$ Taking your example of $n=9$, it is
$$\frac{\binom{9+2}{2} -3(\lfloor{\frac{9}{2}} \rfloor + 1)+2}{6} = \frac{55-3\cdot5+2}{6}=7.$$
