If $k=3$ then you correctly computed $G(1)=1$, $G(2)=2$, and $G(3)=3$, but $$G(4)=\text{mex}(\\{G(1),G(2),G(3)\\})=\text{mex}(\\{1,2,3\\})=0.$$
Hint. Show that for a given $k$, the Grundy function $G$ is periodic of period $k+1$. Note that $G(0)=0$.
Can you take it from here?