## Task A-4.1.

Given is the sequence $\left(a_{n}\right)$,

$$
a_{1}=1, \quad a_{n}=3 a_{n-1}+2^{n-1}, \text { for } n \geq 2
$$

Express the general term of the sequence $a_{n}$ in terms of $n$.
The first solution.

We have

$$
\begin{aligned}
a_{1}= & 1 \\
a_{2}= & 3 a_{1}+2 \\
a_{3}= & 3 a_{2}+2^{2} \\
& \cdots \\
a_{n-1}= & 3 a_{n-2}+2^{n-2} \\
a_{n}= & 3 a_{n-1}+2^{n-1}
\end{aligned}
$$

Multiply the first equation by $3^{n-1}$, the second by $3^{n-2}$, the third by $3^{n-3}, \ldots$, the penultimate by 3,

$$
\begin{aligned}
3^{n-1} a_{1}= & 3^{n-1} \\
3^{n-2} a_{2}= & 3^{n-1} a_{1}+2 \cdot 3^{n-2} \\
3^{n-3} a_{3}= & 3^{n-2} a_{2}+2^{2} \cdot 3^{n-3} \\
& \cdots \\
3 a_{n-1}= & 3^{2} a_{n-2}+2^{n-2} \cdot 3 \\
a_{n}= & 3 a_{n-1}+2^{n-1}
\end{aligned}
$$

and add them all together. We get:

$$
\begin{aligned}
a_{n} & =3^{n-1}+2 \cdot 3^{n-2}+2^{2} \cdot 3^{n-3}+\ldots+2^{n-1} \\
& =3^{n-1}+\frac{2}{3} \cdot 3^{n-1}+\left(\frac{2}{3}\right)^{2} \cdot 3^{n-1}+\ldots+\left(\frac{2}{3}\right)^{n-1} \cdot 3^{n-1} \\
& =3^{n-1} \cdot \frac{1-\left(\frac{2}{3}\right)^{n}}{1-\frac{2}{3}}=3^{n}-2^{n}
\end{aligned}
$$

Therefore, $a_{n}=3^{n}-2^{n}$.