<s>[INST] recursive to explicit sequence I am trying to find the explicit formula for the following recursion:  

$$a_{1}=3,\quad a_{n}=3- \frac{1}{a_{n-1}},\quad n \in \mathbb N,n>1$$ 

I tried in many ways but I cannot find any solution.
Can you help me?
 [/INST] $$\dfrac{a_n - p}{a_n - q} = \dfrac{3- \dfrac{1}{a_{n-1}} - p}{3- \dfrac{1}{a_{n-1}} - q} = \dfrac{(3-p)a_{n-1} - 1}{(3-q)a_{n-1}-1} = \dfrac{3-p}{3-q}\dfrac{a_{n-1} -\dfrac{1}{3-p}}{a_{n-1} -\dfrac{1}{3-q}}$$
Take $p = \frac{1}{3-p}$ and $q = \frac{1}{3-q}$, i.e. take $p,q$ as the two different solutions of $x^2 - 3x + 1 = 0$
we get $$\dfrac{a_n - p}{a_n - q} = \left(\dfrac{3-p}{3-q}\right)^{n-1}\dfrac{a_1 - p}{a_1 - q}$$
Now solve for $a_n$ as function of $p,q,n$ and plug in the values of $p$ and $q$
</s>