There is following recursive function
$$ \begin{equation} a_n= \begin{cases} -1, & \text{if}\ n = 0 \\ 1, & \text{if}\ n = 1\\ 10a_{n-1}-21a_{n-2}, & \text{if}\ n \geq 2 \end{cases} \end{equation} $$
I know this can be rewritten as $$ a_n=7^n-2\cdot3^n $$
But how can I reach that statement? I found this problem on some particular website. My skills are not enough to solve such things. Someone told me I have to read about Generating function but it didn't help me.
I would be thankful if someone explained it to me.