<s>[INST] how many ways can you write a number n as a sum of 1s, 2s and 3s Given $n \in \mathbb{N}$ how many ways can one write $n=a+2b+3c$ for $a,b,c \in \mathbb{N}$.
I have an idea as if I use a a 3-tuple to represent $(a,b,c)$, I can list all of them using two functions $f((a,b,c)) = (a-2,b+1,c)$ and $g((a,b,c)) = (a-1,b-1,c+1)$. Which makes a nice pattern that should be easy to compute for any n however I'm struggling finding an actual equation that works everytime. Right now I have one that works sometimes being; Let $x = \left \lfloor{n/2}\right \rfloor  $, $y = \left \lfloor{n/6}\right \rfloor  $ and $z = x-y$. Then the function $f(n)$ is the count.
$f(n) = 1+x+(c/2)(c+1)+bc-b(b+1)$. However I know it's wrong.
EDIT:
Sorry forgot to add that f(n) should be a function of just n. 
 [/INST] Let $f(n)$ be the number of ways of making $n$ as a sum of only $1$s, $g(n)$ be the number of ways of making $n$ as a sum of only $1$s and $2$s, and $h(n)$ be the number of ways of making $n$ as a sum of only $1$s, $2$s, and $3$s.  
It should be obvious that $f(n) = 1$.  
$g(0) = f(0) = 1$ and $g(1) = f(1) = 1$, since there will not be any $2$s for these small numbers.  For $n \ge 2$, $g(n) = f(n) + g(n - 2) = 1 + g(n-2)$. 
For $n \lt 3$, $h(n) = g(n)$.  For $n \ge 3$, $h(n) = g(n) + h(n-3)$.  
$$
h(n) - h(n-3) = g(n)\\
g(n) - g(n-2) = 1\\
h(n) - h(n-3) - (h(n-2) - h(n-5)) = 1\\
h(n) - h(n-2) - h(n-3) + h(n-5) = 1\\
h(n-1) - h(n-3) - h(n-4) + h(n-6) = 1\\
h(n) - h(n-1) - h(n-2) - h(n-3) + h(n-3) + h(n-4) + h(n-5) - h(n-6) = 1 - 1 = 0\\
h(n) = h(n-1) + h(n-2) - h(n-4) - h(n-5) + h(n-6)\\
$$
So now we've got a linear recurrence. For the Fibonacci linear recurrence, $F(n) = F(n-1) + F(n-2)$, which has a related polynomial of $x^2 - x - 1$, and that polynomial has roots  $\frac{1 \pm \sqrt{5}}{2}$, and the closed form of the Fibonacci series is based on a linear combination of exponentials of those roots, $Fib(n) = k_1 \left(\frac{1 + \sqrt{5}}{2}\right)^n + k_2\left(\frac{1 - \sqrt{5}}{2}\right)^n$.
So the polynomial associated with the $h(n)$ recurrence is $x^6 - x^5 - x^4 + x^2 + x - 1$.  That factors to $ (x  + \frac12 + \frac{\sqrt{3}}{2}i)(x + \frac12 - \frac{\sqrt{3}}{2}i) (x - 1)^3 (x + 1)$  That translates into a closed form expression of the form $(k_1 + k_2 n + k_3 n^2)(1)^n + k_4(-1)^n + k_5(-\frac12 - \frac{\sqrt{3}}{2}i)^n + k_6(-\frac12 + \frac{\sqrt{3}}{2}i)^n$.
</s>