Solution (source code)

= Solution

Define the <continuous function>
$$
h(x)=g(x+a)-g(x)-a,
\qquad 0\leq x\leq(n-1)a.
$$
At the mesh points its values telescope:
$$
\sum_{k=0}^{n-1}h(ka)
=g(na)-g(0)-na=0.
$$
If one term is zero, the result follows immediately. Otherwise the terms cannot all have the same sign, so there are mesh points at which $h$ is positive and negative. The <intermediate value theorem> between those points gives an $x\in[0,(n-1)a]$ with $h(x)=0$. Thus the <telescoping increment lemma> yields
$$
\boxed{g(x+a)=g(x)+a}.
$$