Given the set of integers modulo $n$, can all functions from this set to itself be expressed as polynomials?

Suppose you have a composite $n=ab$, with $a,b>1$. Any function that satisfies $f(0)=0, f(a)=1$ can not be a polynomial otherwise we would have $$0=b\left(f(a)-f(0)\right)=b$$ in $\mathbb Z/n\mathbb Z$, which is a contradiction. However this is not a problem for $n$ prime, where you can use Lagrange interpolation to represent any function as a polynomial.


The 1995 paper On polynomial functions from $\mathbb{Z}_n$ to $\mathbb{Z}_m$ in Discrete Mathematics, Vol. 137, proves the following strongly related result:

Theorem: Every function $f:\mathbb{Z}_n \rightarrow \mathbb{Z}_m$ is a polynomial function if and only if $n$ is not greater than the least prime factor of $m.$

To see the necessity, note that if $p|m$ then the representing polynomial $F \in \mathbb{Z}[x]$ for the function $f$ will satisfy $F(0)\equiv F(p) \pmod p$ so those values cannot be chosen independently.

For the sufficiency, since $n$ is not greater than the least prime factor of $m$ one has $(i-1,j)=1,$ for any $i\neq j$ and $i,j\in \{0,1,\ldots,n-1\}.$ Thus $i-j$ is a unit in $\mathbb{Z}_m.$ Let $(i-j)^{-1} \in \mathbb{Z}_m$ be denoted by $c_{ij}.$

If $f:\mathbb{Z}_n \rightarrow \mathbb{Z}_m$ is given by $f(i)=b_i,$ for $i=0,1,\ldots,n-1$ the following expression $$ F(x)=\sum_{i=0}^{n-1}b_i \prod_{\stackrel{j=0}{j\neq i}}^{n-1} c_{ij}(x-j) $$ will represent the function $f.$


If $F:\Bbb Z/n\Bbb Z\to \Bbb Z/n\Bbb Z$ is given by a polynomial then for each $m \mid n$, $F(a)\equiv F(a+m)\bmod m$. Not all functions satisfy this condition.

If $n$ is squarefree and $F$ satisfies this condition then it is given by a polynomial: let $n=\prod_j p_j$, $c_j \frac{n}{p_j} \equiv 1\bmod p_j$, we'll have $$F(x) =\sum_j c_j \frac{n}{p_j^{e_j}} \sum_{a=0}^{p_j-1} F(a)(1-(x-a)^{p_j-1}).$$

I don't know if there is a simple congruence condition ensuring that $F$ is given by a polynomial when $n$ is not squarefree.