The number of ways to represent a natural number as the sum of three different natural numbers
Solution 1:
If $n=r+s+t$ is a representation of a positive integer as a sum of integers which $r>s>t>0$, then $n-6=(r-3)+(s-2)+(t-1)$ is a representation of $n-6$ as a sum of integers $(r-3) \ge(s-2)\ge(t-1)\ge0$, that is a partition of $n-6$ into at most three parts. Therefore $a_n=c_{n-6}$ where $c_n$ is the number of partitions of $n$ into at most three parts.
By conjugation of partitions, $c_n$ is the number of partitions of $n$ into parts of size at most $3$. So the generating function of the $c_n$ is $$C(x)=\sum_{n=0}^\infty c_nx^n=\frac1{(1-x)(1-x^2)(1-x^3)}.$$ Now use the normal manoeuvres with rational functions to find the $n$-th term: write in partial fractions $$C(x)=\frac{A}{1-x}+\frac{B}{(1-x)^2}+\frac{C}{(1-x)^3}+ \frac{D}{1+x}+\frac{E+Fx}{1+x+x^2}$$ and go from there.
Solution 2:
While I agree that generating functions is how I'd approach it now, the slightly more basic approach from back in the day using just high school techniques, will be simply to count it and account for the double counting using Principle of Inclusion and Exclusion.
Without restriction of equality, and without ordering the integers, there are ${ n- 1 \choose 2 } = \frac{ n^2 - 3n + 2 } { 2 }$ ways. If all of the ways are distinct, that we'd double-count them $3!=6$ times due to the order. This naively leads to $ \frac{ n^2 - 3n + 2 } { 12 } $ which is close to the answer, so we're reasonably on the right track.
How many of these ways have 2 values the same? They will be of the form $ \{a, a, b \}$ with $ 1 \leq a \leq \lfloor \frac{n-1}{2} \rfloor$, so there are $ 3\lfloor \frac{ n-1 } { 2 } \rfloor $ of them.
How many of these ways have 3 values the same? They will be of the form $ \{ a, a, a \}$, so there is 1 if $n$ is a multiple of 3. Let $n_3$ be the indicator variable that $ 3 \mid n$. (See notes for how to write this as floor/ceiling functions.)
So how many ways are distinct?
Clearly we want to subtract off the cases where "2 values are the same".
For "3 values the same", note that it is triple counted in "2-values the same", so we have to add $ 2n_3$ in order for this to just be subtracted once.
That will be
$$ \frac{ n^2 - 3n + 2 } { 2} - 3\lfloor \frac{ n-1 } { 2 } \rfloor +2 n_3.$$
Accounting for the order, we then have to divide by 6, to get
$$ \frac{ n^2 - 3n + 2 } { 12} - \frac{1}{2} \lfloor \frac{ n-1 } { 2 } \rfloor + \frac{1}{3} n_3.$$
It remains to check the various cases of $ n \pmod{6}$ that this value is indeed equal to
$$ \lceil \frac{ n^2 - 6n + 12 } { 12 } \rceil $$
Notes:
- $n_3 = 1 - \lceil \frac{n}{3} \rceil + \lfloor \frac{n}{3} \rfloor $, if we wanted to stick to floor/ceiling functions.
- Naively $ \frac{ n^2 - 3n + 2 } { 12} - \frac{1}{2} ( \frac{ n-1 } { 2 } ) = \frac{ n^2 - 6n + 5}{12}$, which tells us we're very close. We just need to add a (positive) "error term" to account for the other values.
- To verify an identity involving floor/ceiling functions and divisibility indicator variables, checking $ \pmod{k}$ is often the fastest/easiest way. Of course, it's slightly harder to guess what an expression can be simplified into.
- The fanciful name of this approach is Polya enumeration theorem, arising from Group Theory, but the high school student doesn't need to know that.
Solution 3:
Here is a solution inspired by the beautiful Gerry Myerson's one.
Let $a_n$ be a number of representations of $n$ as a sum of three distinct numbers with no matter to ordering.
Thus, easy to see that $a_1=a_2=a_3=a_4=a_5=0,$ $a_6=a_7=1$, $a_8=2$, $a_9=3$,
$a_{10}=4$, $a_{11}=5$, $a_{12}=7$, $a_{13}=8$, $a_{14}=10$, $a_{15}=12,$ $a_{16}=14,$ $a_{17}=16$.
Let $a>b>c\geq1$ be integers and $a+b+c=n$.
Thus, $$n=a+b+c\geq c+2+c+1+c=3c+3,$$ which gives $$c\leq\frac{n}{3}-1$$ and we see that $c$ goes so: $$1\leq c\leq\left[\frac{n}{3}\right]-1.$$
Now, since $$a-c+b-c=n-3c,$$ we see that $b-c$ defines a number of solutions for fixed $c$ and since $$n-3c=a-c+b-c\geq b-c+1+b-c=2(b-c)+1,$$ we obtain $$b-c\leq\frac{n-3c-1}{2},$$ which gives $\left[\frac{n-3c-1}{2}\right]$ solutions.
Id est, $$a_n=\sum_{c=1}^{\left[\frac{n}{3}\right]-1}\left[\frac{n-3c-1}{2}\right].$$ Now, $$a_{n+6}=\sum_{c=1}^{\left[\frac{n+6}{3}\right]-1}\left[\frac{n+6-3c-1}{2}\right]=\sum_{c=1}^{\left[\frac{n}{3}\right]+1}\left[\frac{n+5-3c}{2}\right]=$$ $$=\sum_{c=-1}^{\left[\frac{n}{3}\right]-1}\left[\frac{n-3c-1}{2}\right]=\sum_{c=1}^{\left[\frac{n}{3}\right]-1}\left[\frac{n-3c-1}{2}\right]+\left[\frac{n+2}{2}\right]+\left[\frac{n-1}{2}\right],$$ which gives $$a_{n+6}=a_n+\left[\frac{n+2}{2}\right]+\left[\frac{n-1}{2}\right].$$ Also, $$a_{n+12}=\sum_{c=1}^{\left[\frac{n+12}{3}\right]-1}\left[\frac{n+12-3c-1}{2}\right]=\sum_{c=1}^{\left[\frac{n}{3}\right]+3}\left[\frac{n+11-3c}{2}\right]=\sum_{c=-3}^{\left[\frac{n}{3}\right]-1}\left[\frac{n-3c-1}{2}\right]=$$ $$=\sum_{c=1}^{\left[\frac{n}{3}\right]-1}\left[\frac{n-3c-1}{2}\right]+\left[\frac{n+8}{2}\right]+\left[\frac{n+5}{2}\right]+\left[\frac{n+2}{2}\right]+\left[\frac{n-1}{2}\right],$$ which gives $$a_{n+12}=a_n+\left[\frac{n+8}{2}\right]+\left[\frac{n+5}{2}\right]+\left[\frac{n+2}{2}\right]+\left[\frac{n-1}{2}\right].$$ Thus, $$a_{n+12}-2a_{n+6}+a_n=\left[\frac{n+8}{2}\right]+\left[\frac{n+5}{2}\right]-\left[\frac{n+2}{2}\right]-\left[\frac{n-1}{2}\right]=$$ $$=\left[\frac{n+2}{2}\right]+3+\left[\frac{n-1}{2}\right]+3-\left[\frac{n+2}{2}\right]-\left[\frac{n-1}{2}\right]=6,$$ Now, we'll consider six cases.
- $n=6k$, where $k\geq1$.
Thus, for $k\geq3$ we obtain: $$6(k-2)=\sum_{i=3}^{k}\left(a_{6i}-a_{6i-6}-\left(a_{6i-6}-a_{6i-12}\right)\right)=$$
$$=a_{6k}-a_{6k-6}-(a_{12}-a_6)=a_{6k}-a_{6k-6}-(7-1),$$ which gives
$$a_{6k}-a_{6k-6}=6k-6.$$
Since for $k=2$ the last equality is also true, we see that
$$a_{6k}-a_{6k-6}=6k-6$$ is true for any integer $k\geq2$,
which gives
$$\sum_{i=2}^k(a_{6i}-a_{6i-6})=\sum_{i=2}^k6(i-1)$$ or
$$a_{6k}-a_6=6\cdot\frac{k(k-1)}{2}$$ or
$$a_{6k}=3k^2-3k+1$$ and since for $k=1$ it's also true, we obtain that
$$a_{6k}=3k^2-3k+1$$ is true for any integer $k\geq1$.
Also, $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2-36k+12}{12}\right]=3k^2-3k+1,$$ which says that we solved our problem in this case.
- $n=6k+1$, where $k\geq1$.
In this case by the same way we obtain: $$a_{6k+1}-a_{6k-5}=6k-5,$$ $$a_{6k+1}=3k^2-2k$$ and indeed, $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2+12k+1-36k-6+12}{12}\right]=3k^2-2k.$$ 3. $n=6k+2$, where $k\geq1$.
Here we obtain: $$a_{6k+2}-a_{6k-4}=6k-4,$$ $$a_{6k+2}=3k^2-k$$ and $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2+24k+4-36k-12+12}{12}\right]=3k^2-k.$$ 4. $n=6k+3$, where $k\geq1$.
Here we obtain: $$a_{6k+3}-a_{6k-3}=6k-3,$$ $$a_{6k+3}=3k^2$$ and $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2+36k+9-36k-18+12}{12}\right]=3k^2.$$ 5. $n=6k+4$, where $k\geq1$.
Here we obtain: $$a_{6k+4}-a_{6k-2}=6k-2,$$ $$a_{6k+4}=3k^2+k$$ and $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2+48k+16-36k-24+12}{12}\right]=3k^2+k.$$ 6. $n=6k+5$, where $k\geq1$.
Here we obtain: $$a_{6k+5}-a_{6k-1}=6k-1,$$ $$a_{6k+5}=3k^2+2k$$ and $$\left[\frac{n^2-6n+12}{12}\right]=\left[\frac{36k^2+60k+25-36k-30+12}{12}\right]=3k^2+2k$$ and we are done!
Quits really sadism!