- Which polynomials induce the zero function mod $n$?
In particular:
What is the polynomial of least degree that induces the zero function mod $n$?
What is the monic polynomial of least degree that induces the zero function mod $n$?
These are not vacuous questions because of the following general result:
If $r$ is the maximum exponent in the prime factorization of $n$, then $x \mapsto x^{r+\lambda (n)}-x^r$ is the zero function mod $n$. [Wikipedia]
Here, $\lambda$ is the Carmichael function.
- When is $x^{r+\lambda (n)}-x^r$ the monic polynomial of least degree that induces the zero function mod $n$?
Fermat's theorem implies that $x^n-x$ is the answer for $n$ prime: all polynomials that induce the zero function mod $n$ are a multiple of $x^n-x$. How can this be generalized to composite $n$?
Here are some other examples: $$ \begin{array}{rll} n & L_n: \text{least degree} & M_n: \text{least degree monic} \\ 2 & x^2+x \\ 3 & x^3-x \\ 4 & 2(x^2+x) & x^4-x^2 \\ 5 & x^5-x \\ 6 & 3(x^2+x) & x^3-x \\ 7 & x^7-x \\ 8 & 4(x^2+x) & x^4+2x^3+3x^2+2x = x(x+1)(x^2+x+2) \\ 9 & 3(x^3-x) & x^8-x \quad (???) \\ 10 & 5(x^2+x) & x^5-x \\ 11 & x^{11}-x \\ 12 & 6(x^2+x) & x^4+5x^2+6x = x(x+1)(x^2-x+6) \\ 13 & x^{13}-x \\ 14 & 7(x^2+x) & ??? \\ 15 & 5(x^3-x) & x^5-x \\ 21 & 7(x^3-x) & ??? \\ 24 & 12(x^2+x) & x^4+2x^3+11x^2+10x = x(x+1)(x^2+x+10) \end{array} $$
It seems clear that $L_{2m}=m(x^2+x)$, because $x^2+x$ is always even. More generally,
Is $L_{pq} = qL_p$ and $M_{pq}=L_q$ for $p<q$ primes?
If $n=pm$ and $p$ is smallest prime divisor of $n$, then is $L_{pm}=mL_p$?
Corrections and additions welcome. Please collect partial results as answers.
As proved in another answer, the polynomials that induce the zero function mod $n$ are precisely those that, when written in the form $$f(x) = \sum_{k} c_k x^{\underline k},$$ satisfy the property that $c_k$ is divisible by $n\,/\gcd(n, k!)$, for each $k$. (Here, $x^{\underline k}$ is the "falling factorial": $x^{\underline k} = x(x-1)\cdots(x-k+1)$.)
That answers the first question, and to answer the other questions:
I'm assuming you don't accept polynomials like $f(x) = 0$ or $f(x) = n$ or $f(x) = nx + 2n$, etc, i.e. you want the coefficients to be nonzero mod $n$. When $k$ is less than the smallest factor of $n$, we get $\gcd(n, k!) = 1$, which means that $c_k$ is a multiple of $n$. We can take $c_k$ nonzero mod $n$, when $\gcd(n, k!) > 1$, which happens when $k$ is the smallest prime factor of $n$, say $p$. Then we need $c_k$ to be a multiple of $n / \gcd(n, k!) = n / p$, so we can take $c_k$ to be $n/p$ and all other coefficients $0$, so that $f(x) = (n/p) x^{\underline p} = (n/p) x(x-1)\cdots(x-p+1)$. Other polynomials of degree $p$ may also be possible.
This gives the following table, as in the question:
$$ \begin{array}{rll} n & L_n\text{ from question} & L_n\text{ from this answer} \\ 2 & x^2+x & (2/2)x^{\underline 2} = x^2 - x \\ 3 & x^3-x & (3/3)x^{\underline 3} = x(x-1)(x-2) = x^3 - 3x^2 + 2x \\ 4 & 2(x^2+x) & (4/2)x^{\underline 2} = 2(x^2 - x) \\ 5 & x^5-x & (5/5)x^{\underline 5} = x^5 - 10x^4 + 35x^3 - 50x^2 + 24x \\ 6 & 3(x^2+x) & (6/2)x^{\underline 2} = 3(x^2 - x) \\ 7 & x^7-x & (7/7)x^{\underline 7} = … \\ 8 & 4(x^2+x) & (8/2)x^{\underline 2} = 4(x^2 - x) \\ 9 & 3(x^3-x) & (9/3)x^{\underline 3} = 3(x^3 - 3x^2 + 2x) \\ 10 & 5(x^2+x) & (10/2)x^{\underline 2} = 5(x^2-x) \\ 11 & x^{11}-x & (11/11)x^{\underline{11}} = … \\ 12 & 6(x^2+x) & (12/2)x^{\underline 2} = 6(x^2 - x) \\ 13 & x^{13}-x & (13/13)x^{\underline{13}} = … \\ 14 & 7(x^2+x) & (14/2)x^{\underline 2} = 7(x^2 - x) \\ 15 & 5(x^3-x) & (15/3)x^{\underline 3} = 5(x^3 - 3x^2 + 2x) \\ 21 & 7(x^3-x) & (21/3)x^{\underline 3} = 7(x^3 - 3x^2 + 2x) \\ 24 & 12(x^2+x) & (24/2)x^{\underline 2} = 12(x^2 - x) \end{array} $$
so you see it matches in each case (is congruent mod $n$). It's not too hard to prove that for prime $p$, $x^{\underline p}$ is the same as $x^p - x$ modulo $p$.
For this we need $c_d = 1$ where $d$ is the degree of the polynomial, and this must be a multiple of $n / \gcd(n, d!)$, so $n / \gcd(n, d!)$ must be $1$, or in other words $\gcd(n, d!) = n$ which means that $n$ divides $d!$. This is called the Kempner function. So we can take $c_d = 1$ and all other $c_k$ to be $0$.
This gives the following table, for the examples in the question:
$$ \begin{array}{rll} n & M_n\text{ from question} & M_n\text{ from this answer} \\ 2 & x^2+x & x^{\underline 2} \\ 3 & x^3-x & x^{\underline 3} \\ 4 & x^4-x^2 & x^{\underline 4} = x^4 - 6 x^3 + 11 x^2 - 6 x \\ 5 & x^5-x & x^{\underline 5} \\ 6 & x^3-x & x^{\underline 3} = x^3 - 3 x^2 + 2 x \\ 7 & x^7-x & x^{\underline 7} \\ 8 & x^4+2x^3+3x^2+2x & x^{\underline 4} \\ 9 & x^8-x \quad (???) & x^{\underline 6} \\ 10 & x^5-x & x^{\underline 5} \\ 11 & x^{11}-x & x^{\underline{11}} \\ 12 & x^4+5x^2+6x & x^{\underline 4} \\ 13 & x^{13}-x & x^{\underline{13}} \\ 14 & ??? & x^{\underline 7} \\ 15 & x^5-x & x^{\underline 5} \\ 21 & ??? & x^{\underline 7} \\ 24 & x^4+2x^3+11x^2+10x & x^{\underline 4} \end{array} $$
which answers some of the $???$s in the question, corrects one of them ($M_9$ has degree $6$, not $8$), gives the same polynomials mod $n$ for some $n$, and some truly different (though they can be checked to work: so $M_n$ is not unique as a polynomial, though the polynomial function (mod $n$) itself is unique).
As "the monic polynomial of least degree" is not unique (see the examples just above), the relevant question is to ask when the degree matches. For this to happen, $r + \lambda(n)$ must be the Kempner function of $n$ (let's call it $K(n)$), i.e. the smallest $k$ such that $n$ divides $k!$. This happens when either:
The proof is as follows. First, for prime powers $n = p^r$, note that $\lambda(n) = p^{r-1}(p-1)$ while $K(n) \le rp$ (it's equal when $r \le p$, and smaller for larger $r$). So for them to be equal, we need $r + p^{r-1}(p-1) \le rp$ which happens only when $r=1$ or for $(p, r) = (2, 2)$. Next, when $n$ has prime factorization $n = p_1^{e_1} \cdots p_m^{e_m}$, the Carmichael function $\lambda(n) = \operatorname{lcm}(\lambda(p_1^{e_1}), \ldots, \lambda(p_m^{e_m}))$. Meanwhile, the RHS $K(n)$ is $\max(K(p_1^{e_1}), \ldots, K(p_m^{e_m}))$. Now if the maximum on the right is attained at a certain $J$, then the same inequality gives that either $e_J = 1$ and $r = 1$ so $n$ is a product of distinct primes and the property above needs to hold so that the LCM of the values $(p_j - 1)$ doesn't exceed $p_m - 1$, or else the special case of $J = 1$, $p_1 = 2$, $e_1 = 2$, and other primes if any are less than $2^2$ so $n$ is either $2^2 = 4$ or $2^2 \cdot 3 = 12$.
To answer the final two questions (and the comment before them):
Yes we can take $m(x^2 + x)$; note that our above method gives the polynomial $(2m/m)x^{\underline 2} = m(x^2 - x)$ which is the same mod $2m$.
For $L_p$ we can take $(p/p)x^{\underline p}$ and for $L_{pq}$ we can take $(pq/p) x^{\underline p}$, so yes for the first part. Similarly, for the second part, we can take $L_q = x^{\underline q}$ and $M_{pq}$ to be $x^{\underline q}$ as well, as $pq$ divides $q!$ when $p < q$.
Yes, as above, for $L_p$ we take $x^{\underline p}$ and for $L_{pm}$ we take $(pm/p) x^{\underline p}$.