Short version: What is $$\min_{f: f(x)=0 \iff n|x} |\{f(x) \bmod n: x \in \mathbb{Z}\}|$$ where $f$ is a polynomial over $\mathbb{Z}$ (or equivalently $\mathbb{Z}/n\mathbb{Z}$)?
For example, for $n = 15$, the polynomial $f(x) = x^4$ takes only four possible values $ \bmod {15}$ (namely: $0, 1, 6, 10$), and we can test whether $x$ is divisible by $15$ by checking whether $x^4 \equiv 0 \pmod {15}$.
As a motivating example, consider the following. For a prime number $n$, consider the polynomial $f(x) = x^{n-1}$. Modulo $n$, this maps $0$ to $0$ and any nonzero number to $1$ (by Fermat's little theorem). So $f(x)$ has only two residue classes mod $n$, and moreover looking at which of these two values $f(x) \bmod n$ takes is enough to say whether or not $x$ is divisible by $n$. So we can say that this $f$ "separates" $0$ (from the other residues), and for this $f$, the set of all possible residues has size just $2$.
When $n$ is not prime, things are less straightforward, though they sometimes work out nicely:
Modulo $n = 4$, consider the polynomial $f(x) = x^3 + x$. This takes $0$ to $0$ and all other values to $2$.
Modulo $n = 8$, the best we can do is still the same polynomial $f(x) = x^3 + x$, taking $0$ to $0$ and other residues to one of $0, 2, 4, 6$.
Modulo $n = 9$, the best we can do is the polynomial $x^5 + x^3 + x$, taking the three values $0, 3, 6$.
This motivates the following definitions.
Define a discriminating polynomial $f(x)$ as one for which $f(x) \equiv f(0) \pmod n \iff x \equiv 0 \pmod n$. In other words, $f$ separates $0$ from nonzero mod $n$. Clearly, adding a constant does not change whether a polynomial is discriminating so we can assume w.l.o.g that $f(0) = 0$ and $f(x) ≠ 0$ if $x ≠ 0$.
Define a minimally discriminating polynomial as a discriminating polynomial for which the set $\{f(x) \bmod n | x \in \mathbb{Z}\}$, i.e. the set of all residues attained by the polynomial, has the smallest size. Call the size of this set $S(n)$.
So the question is: what is $S(n)$, for a given value of $n$?
Some things I've tried:
When $n$ is prime, the answer is $S(n) = 2$, as we saw above.
When $n = ab$ is the product of two relatively prime numbers (i.e. $\gcd(a, b) = 1$), then $S(n) = S(a)S(b)$. (We can prove this by showing that it's both a lower bound and an upper bound, using the Chinese remainder theorem.)
This means that $S$ is a multiplicative function, so it is enough to determine the values of $S$ at prime powers.
By a previous answer, I know how to enumerate all the polynomial functions mod $n$ without repetition, so I tried to find the results with a program. Unfortunately the number of polynomial functions can grow quite large, so I was only able to determine the following values:
- [As mentioned above] For prime $p$, taking $f(x) = x^{p-1}$ gives $S(p) = 2$.
- For $n = 4$, taking $f(x) = x^3 + x$ gives $S(4) = 2$.
- For $n = 8$ and $n = 16$, still the same $f$ is optimal, but gives $S(8) = 4$ and $S(16) = 8$. I'm willing to believe at this point that $S(2^n) = 2^{n-1}$.
- For $n = 9$, taking $x^5 + x^3 + x$ gives $S(9) = 3$.
So from these values, we know $S(n)$ for all $n$ from $2$ to $24$: the sequence is $2, 2, 2, 2, 4, 2, 4, 3, 4, 2, 4, 2, 4, 4, 8, 2, 6, 4, 4, 4, 2, 8$ which does not match anything in OEIS. I also tried subtracting $1$ (counting only the nonzero residues), but $1, 1, 1, 1, 3, 1, 3, 2, 3, 1, 3, 1, 3, 3, 7, 1, 5, 3, 3, 3, 1, 7$ is not on OEIS either.
In any case, the remaining question is to calculate $S(p^k)$ for prime $p$ and integer exponent $k \ge 2$.