Find all non-negative integer $n$ that there exists a non-periodic function $f:\Bbb R->\Bbb R\quad f(x+1)+f(x-1)=\sqrt nf(x)\forall x$.
My attempt:
$f(x+2)+f(x)=\sqrt n\cdot f(x+1)$
$\sqrt n \cdot (f(x+1)+f(x+3))=n\cdot f(x+2)$
$f(x+2)+f(x+4)=\sqrt n\cdot f(x+3)$
Therefore $$f(x)+f(x+4)=(n-2)\cdot f(x+2)\tag{*}$$
$n=0\implies f(x)=-f(x+2)\implies f(x)=f(x+4)$
$n=1\implies f(x+2)+f(x)=f(x+1)\,$ and $\,f(x+3)+f(x+1)=f(x+2)\implies f(x)=f(x+3)$
$n=2\quad(*)\implies f(x)+f(x+4)=0\,$ A similar argument hold for $n=0$.
$n=3\quad(*) \implies f(x)+f(x+4)=f(x+2).$ A similar argument hold for $n=1.$
$n=4\quad f(x)=x$ works.
$\forall n>4,f(x)$ can be defined recursively:
$i)\;$ $f(x)=f(\lfloor x\rfloor)\forall x$
$ii)\;$ $f(0)=0,\;f(1)=1$
$iii)\;$ $f(x)+f(x+2)=\sqrt n \cdot f(x+1)\;\forall x\in\Bbb Z$
It's easy to show that this satisfy the riginal functional equation, but we still need to prove it's non-periodic. It's sufficient to prove $iii)$ is monotonic.
$f(x+2)=\sqrt n\cdot f(x+1)-f(x)>2\cdot f(x+1)-f(x)\ge f(x+1)$
Is my proof correct?
Any help appreciated.
Hint.
Assuming $f(x) = \lambda^x$ we have
$$ \lambda^{x+1}+\lambda^{x-1} = \sqrt{n}\lambda^x\Rightarrow \left(\lambda+\frac{1}{\lambda}=\sqrt n\right)\lambda^x $$
hence
$$ \lambda = \frac 12\left(\sqrt n\pm\sqrt{n-4}\right) $$