Let $n$ be a positive integer. Determine the function $f(n)$ if $f(1)=1, f(2)=3$ and

$$
2 f(n-2)+f(n-1)=f(n)
$$
According to Adataink,

$$
f(2)=2 f(1)+1=2 f(1)+(-1)^{2} \ldots
$$

Suppose that

$$
f(n)=2 f(n-1)+(-1)^{n} \ldots
$$

According to the condition:

$$
f(n+1)=2 f(n-1)+f(n) \ldots
$$

However, if 2) is true, then

$$
2 f(n-1)=f(n)-(-1)^{n}
$$

Substitute this into 3):

$$
f(n+1)=f(n)-(-1)^{n}+f(n)=2 f(n)+(-1)^{n+1} \ldots
$$

If 2) is true, then 4) is also true. Since the value of the function can be calculated for $n=2$ according to (1), the same law can be used to calculate $f(3), f(4)$, and so on, up to $f(n)$. Now,

$$
\begin{aligned}
f(n) & =2 f(n-1)+(-1)^{n}=2^{2} f(n-2)+2(-1)^{n-1}+(-1)^{n}= \\
& =2^{3} f(n-3)+2^{2}(-1)^{n-2}-2(-1)^{n-1}+(-1)^{n}=\ldots= \\
& =2^{n-2} f(2)+2^{n-3}(-1)^{3}+2^{n-4}(-1)^{4}+\ldots+2^{0}(-1)^{n}= \\
& =2^{n-1}+2^{n-2}+2^{n-3}(-1)^{3}+\ldots+2^{n-4}(-1)^{4}+\ldots+2^{0}(-1)^{n}
\end{aligned}
$$

If $n$ is odd,

$$
\begin{gathered}
f(n)=2^{n-1}+\left(2^{n-2}-2^{n-3}\right)+\left(2^{n-4}-2^{n-5}\right)+\ldots+(2-1)= \\
=2^{n-1}+2^{n-3}+2^{n-5}+\ldots+2^{4}+2^{2}+1
\end{gathered}
$$

Here we have a geometric progression, where the first term is 1, the common ratio is $2^{2}$, and the number of terms is: $\frac{n-1}{2}+1$. Thus, the sum of the series is

$$
f(n)=\frac{2^{2}\left(\frac{n-1}{2}+1\right)-1}{2^{2}-1}=\frac{2^{n+1}-1}{3}=\frac{2^{n+1}+(-1)^{n}}{3}
$$

If $n$ is even, then

$$
\begin{aligned}
f(n) & =2^{n-1}+\left(2^{n-2}-2^{n-3}\right)+\left(2^{n-4}-2^{n-5}\right)+\ldots+\left(2^{2}-2\right)+1= \\
& =2^{n-1}+2^{n-3}+2^{n-5} \ldots+2^{3}+2+1= \\
& =2\left[2^{n-2}+2^{n-4}+2^{n-6} \ldots+2^{2}+1\right]+1= \\
& =2 \frac{2^{2}\left(\frac{n-2}{2}+1\right)-1}{2^{2}-1}+1=2 \frac{2^{2 n}-1}{3}+1=\frac{2^{n+1}-2}{3}+1= \\
& =\frac{2^{n+1}+1}{3}=\frac{2^{n+1}+(-1)^{n}}{3}
\end{aligned}
$$

Therefore, whether $n$ is even or odd,

$$
f(n)=\frac{2^{n+1}+(-1)^{n}}{3}
$$

György Taksony (Year VII, Bp.)