TITLE: Functions $f:\mathbb Z\to\mathbb Q$ satisfying $f\left(\frac{x+y}3\right)=\frac{f(x)+f(y)}2$ knowing that $\frac{x+y}3\in\mathbb Z$
QUESTION [9 upvotes]: What is the solution of the following functional equation? (I must confess it is a headache for me.)

Find all the functions $ f : \mathbb Z \to \mathbb Q $ such that
$$ f \left( \frac { x + y } 3 \right) = \frac { f ( x ) + f ( y ) } 2 $$
fora ll $x , y \in \mathbb Z $ such that $ \frac { x + y } 3 \in \mathbb Z $.

I'd appreciate your help and comments. I've tried it a lot but until today I'm not able to solve it... :/

REPLY [9 votes]: The function $f$ is necessarily constant. 
We proceed by induction. Note that 
$$
f(3k)=\frac{f(3k)+f(3k)}2=f\left(\frac{3k+3k}3\right)=f(2k),
$$
and
$$
f(k)=f\left(\frac{2k+k}3\right)=\frac{f(2k)+f(k)}2,
$$
from where $f(2k)=f(k)$. In particular, $f(3)=f(2)=f(1)$.
We have $f(1)=f(\frac{0+3}3)=\frac{f(0)+f(3)}2=\frac{f(0)+f(1)}2$, so $f(0)=f(1)$. Now assume that $f(0)=f(1)=\cdots=f(k)$.  Then we do the inductive step:
$$
f(k+1)=f\left(\frac{3k+3}3\right)=\frac{f(3k)+f(3)}2=\frac{f(k)+f(1)}2=f(k).
$$
As mentioned by Hagen, from $f(0)=\frac{f(k)+f(-k)}2$ we get $f(-k)=2f(0)-f(k)$; as $f(k)=f(0)$ for positive $k$, we get that $f(k)=f(0)$ for all $k\in \mathbb Z$.