TITLE: Polynomial that indicates whether or not $x = 1 \pmod n$.
QUESTION [8 upvotes]: For each $n$, is there a polynomial that takes representatives $x \in \Bbb{Z}$ for $\bar{x} \in \Bbb{Z}_n$, and returns whether or not $x = 1 \pmod n$? 
For example, $n = 2$.  Then $x \mapsto x \pmod{2}$ works.  Is there a general formula for the $n$th modulus?
I'm stuck on case $n= 3$. 
Let's loosen the criteria, we can use any of the classical elementary functions.  So exponentiation will work:
$$
n = 3: \\
f(x) = 2^x - 1 \pmod 3\\
0 \to 2^0 - 1 = 1 - 1 = 0 \pmod 3\\
1 \to 2^1 - 1 = 1 \pmod 3\\
2 \to 2^2 - 1 = 3 = 0 \pmod 3
$$

REPLY [2 votes]: One definition of indicate is $P(x) \equiv 0 \bmod n$ iff $x \not\equiv 1 \bmod n$.
With this definition, $x^3+x^2$ works for $n=4$.
$x(x-2)(x-3)$ from @QC_QAOA's answer also works for $n=4$.
However, @QC_QAOA's construction fails for $n=6$. In fact, it fails for every composite number $n>4$.
In fact, no polynomial works for $n=6$ because $x^3-x$ induces the zero function and no polynomial of degree at most $2$ works. (I've tried all of them.)