Problem

Source: 2012 China TST Test 2 p6

Tags: function, modular arithmetic, algebra, functional equation, number theory



Given an integer $n\ge 2$, a function $f:\mathbb{Z}\rightarrow \{1,2,\ldots,n\}$ is called good, if for any integer $k,1\le k\le n-1$ there exists an integer $j(k)$ such that for every integer $m$ we have \[f(m+j(k))\equiv f(m+k)-f(m) \pmod{n+1}. \] Find the number of good functions.