<s>[INST] Find all non-negative integer $n$ that satisfy $f(x+1)+f(x-1)=\sqrt nf(x)$ 
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.
 [/INST] For a nonnegative integer $n$, the roots of the polynomial $t^2-\sqrt{n}\,t+1$ are primitive $k$-th roots of unity for some integer $k>0$ if and only if $n\leq 3$.  (Note that $k=4$ for $n=0$, $k=6$ for $n=1$, $k=8$ for $n=2$, and $k=12$ for $n=3$.)  This shows that any solution $f:\mathbb{R}\to\mathbb{R}$ to the functional equation
$$f(x+1)+f(x-1)=\sqrt{n}\,f(x)\text{ for all }x\in\mathbb{R}$$
is periodic for each $n=0,1,2,3$.  Cesareo gave nonperiodic solutions for integers $n\geq 4$.

Indeed, for $n=0$, we get
$$f(x+4)=-f(x+2)=f(x)\text{ for all }x\in\mathbb{R}\,.$$
For $n=1$, we have
$$\begin{align}f(x+3)&=f(x+2)-f(x+1)
\\&=\big(f(x+1)-f(x)\big)-f(x+1)
\\&=-f(x)\text{ for every }x\in\mathbb{R}\,,\end{align}$$
whence $$f(x+6)=-f(x+3)=f(x)\text{ for all }x\in\mathbb{R}\,.$$
For $n=2$, we have
$$\begin{align}
f(x+4)&=\sqrt{2}\,f(x+3)-f(x+2)\\&=\sqrt{2}\,\big(\sqrt{2}\,f(x+2)-f(x+1)\big)-f(x+2)\\&=f(x+2)-\sqrt{2}\,f(x+1)\\&=-f(x)\text{ for each }x\in\mathbb{R}\,,\end{align}$$
making
$$f(x+8)=-f(x+4)=f(x)\text{ for every }x\in\mathbb{R}\,.$$
Finally, for $n=3$, we have
$$\begin{align}
f(x+6)&=\sqrt{3}\,f(x+5)-f(x+4)\\&=\sqrt{3}\,\big(\sqrt{3}\,f(x+4)-f(x+3)\big)-f(x+4)
\\&=2\,f(x+4)-\sqrt{3}\,f(x+3)\\&=2\,\big(\sqrt{3}\,f(x+3)-f(x+2)\big)-\sqrt{3}\,f(x+3)
\\&=\sqrt{3}\,f(x+3)-2\,f(x+2)\\&=\sqrt{3}\,\big(\sqrt{3}\,f(x+2)-f(x+1)\big)-2\,f(x+2)
\\&=f(x+2)-\sqrt{3}\,f(x+1)=-f(x)
\end{align}$$
for all $x\in\mathbb{R}$.  Consequently,
$$f(x+12)=-f(x+6)=f(x)\text{ for all }x\in\mathbb{R}\,.$$
</s>