On the sequence $n! \bmod p$

We prove, that the sequence $1!, 2!, 3!, \dots$ produces at least $(\sqrt{2} + o(1))\sqrt{p}$ distinct residues modulo prime $p$. Moreover, factorials on an interval $\mathcal{I} \subseteq \{0, 1, \dots, p - 1\}$ of length $N>p^{7/8 + \varepsilon}$ produce at least $(1 + o(1))\sqrt{p}$ distinct residues modulo $p$. As a corollary, we prove that every non-zero residue class can be expressed as a product of seven factorials $n_1! \dots n_7!$ modulo $p$, where $n_i = O(p^{6/7+\varepsilon})$ for all $i=1,\dots,7$, which provides a polynomial improvement upon the preceding results.


Introduction
Wilson's theorem represents one of the most elegant results in elementary number theory.It states that if p is a prime number, then (p − 1)! = −1 mod p.As one of its simple corollaries, we note that (p − 2)! = 1! mod p, and thus not all the residues from A(p) := {i! mod p : i ∈ [p − 1]} are distinct.Erdős conjectured [16], that this is not the only coincidence, i.e., that |A(p)| < p−2.Surprisingly, despite the long history of this natural problem, Erdős' conjecture remains widely open though verified [17] for all primes p < 10 9 .At the same time, it is widely believed (see [2,6] and [12], F11) that the elements of A(p) may be considered as more or less 'independent uniform random variables' for large p.In particular, it is conjectured that as p → ∞.However, the best lower bound up to now is due to García [10]: Theorem (García).
The strategy in [10]  One of the natural ways to generalize this problem is to consider it in a 'short interval' setting (see [8,9,13,15]).Throughout this paper, let p be a large enough prime and L, N be integers such that 0 < L + 1 < L + N < p.Following Garaev and Hernández [8], we define a 'short interval' analogue of A(p) as follows: As L will not play any role, we write A N for short.To bound the cardinality of this set from below, it is usually fruitful to estimate the size of A N /A N , the set of pairwise fractions, since we trivially have The first lower bounds on the size of this set of fractions were linear on N (see [9,13]), while Garaev and Hernández [8] found the following logarithmic improvement.
Theorem (Garaev-Hernández).Let p 1/2+ε < N < p/10.Then The strategy in [8] was to observe A N /A N to contain the sets X 1 , X 2 , . . ., X M defined as and then prove X j 's to be 'large', but their intersections X k ∩ X j to be 'small', which makes inclusion-exclusion formula applicable: In the present paper we give the following improvement of this result.
where c, c 1 , c 2 , c 3 , c 4 , c 5 > 0 are some absolute constants, whose values can be extracted from the proof.
Corollary 2. For N p 7/8 log p, To derive it, we continue the strategy from [8] as follows: using strong results from Algebraic Geometry, we prove 'best possible' bounds for prime k, j.Then we observe, that bounds on sets X j and their intersections imply they behave 'too independently', and therefore the size of their union is at least p + o(p) (see Lemma 1), which implies that A N /A N has size at least p + o(p).This strategy turns out to be helpful when proving Theorem 1 as well.
One of the nice applications of these results deals with representation of the residues as a product of several factorials.It is not hard to see that the classical Wilson's theorem implies the following.Any given a ∈ [p − 1] can be represented1 as a product of three factorials . The aforementioned conjecture on the 'randomness' of A(p) implies that even two factorials are enough.However, if we add an additional constraint the all n i should be of the magnitude o(p) as p → ∞, it becomes not so clear how many factorials are required.Garaev, Luca, and Shparlinski [9] coped with seven.
Theorem (Garaev, Luca, and Shparlinski).Fix any positive ε < 1/12.Then for all prime p, every residue class a ≡ 0 mod p can be represented as a product of seven factorials, During the last two decades, the number of multipliers from the last theorem was not reduced even to 6.However, there were certain improvements on the value of n 0 .García [11] showed that the Theorem above holds with n 0 = O(p 11/12 log 1/2 p), while Garaev and Hernández [8] relaxed it to O(p 11/12 log −1/2 p).Since our new Theorem 2 improves the bounds used in the latter proof, one can obtain a slight (again, polynomial) improvement on the value of n 0 by following the same proof.
Theorem 3. Fix any positive ε < 1/7.Then for all prime p, every residue class a ≡ 0 mod p can be represented as a product of seven factorials, The remainder of the text has the following structure.In Section 2 we introduce some notations and useful lemmas, in Section 3 we prove results on images of 'generic' polynomials, in Section 4 we apply these results to polynomials P j (x) = (x + 1) . . .(x + j), and, finally, in Sections 5 and 6 wee prove theorems 1 and 2.

Conventions and Preliminary Results
Here and below, p denotes a large prime number.Whenever A is a set, we identify it with its indicator function, meaning Throughout the paper, the standard notation , , and respectively O and Ω is applied to positive quantities in the usual way.That is, X Y, Y X, X = O(Y ) and Y = Ω(X) all mean that Y cX, for some absolute constant c > 0.
Otherwise it is indecomposable.We recall that for any integer d > 0 and a ∈ F p , the Dickson polynomial There is also an explicit formula for it: For a positive integer j define the polynomial Given a set A and a polynomial P ∈ F p [x], denote by P (A) the set {P (a) (mod p) : a ∈ A}.
A key lemma to estimate the union of sets: . ., A n be finite sets, and let a b be positive integers, such that the properties hold:

On images of generic polynomials
The two following results seem to be well-known, yet not explicitly written in the literature (see [5], [4] for more information on related questions); we prove them in here for the sake of transparency.
Lemma 2. Let P ∈ F p [x] of degree d be such that P (x)−P (y) x−y is absolutely irreducible over F p , and let I be an arithmetical progression in F p , then: of maximal degree d be such that P (x) − Q(y) is absolutely irreducible over F p , and let I be an arithmetical progression in F p , then: We postpone their proofs until the end of the section, and formulate some helpful results, which are only to be used in this section.
Let us also define suppose that φ(P, Q) is absolutely irreducible over F p .Then where d is a degree of φ(P, Q).
Proof.We recall the modification of classical Lang-Weil result [14], with error term due to Aubry and Perret [1]: Theorem (Lang-Weil).Let F q be a finite field.Let X ⊆ A 2 Fq be a geometrically irreducible hypersurface of degree d.Then Since φ(P, Q)(x, y) is absolutely irreducible over F p , its set of zeros is (by definition) a geometrically irreducible hypersurface, and therefore the Lang-Weil Theorem is applicable.This implies the conclusion of the lemma.
Given a subset I ⊆ F p , let us define We need the following lemma, proof of which is already contained in [8] but we write it down in full generality for explicity.
Lemma 5. Let P, Q ∈ F p [x] be such that φ(P, Q) has no linear divisors.Let I be an arithmetical progression in F p .Then , where d is a degree of φ(P, Q).
Proof.We recall the statement of Lemma 1 in [8] (originated in [3]): Theorem (Bombieri, Chalk-Smith).Let (b 1 , b 2 ) ∈ F p × F p be a nonzero vector and let f (x, y) ∈ F p [x, y] be a polynomial of degree d 1 with the following property: there is no c ∈ F p for which the polynomial f (x, y) is divisible by b 1 x + b 2 y + c.Then In what follows, we will need a bit of Discrete Fourier Transform in F p .Given function f : One can easily verify the Fourier Inverse Transform formula: We also need the following well-known result.Let I be a (finite) arithmetic progression in F p .Then Let us consider I as a characteristic functions of a set.Then Last summand might be bounded as This completes the proof.

Properties of polynomials P j
Let us deduce the following simple lemma: Lemma 6.For given 5 j < p, the polynomial P j (x) ∈ F p [x] is not equal to αD j,a (x + b) + c for α, a, b, c ∈ F p .Moreover, if j is prime, then P j (x) is indecomposable.
Proof.The second assertion is clear since deg P j = j.The first assertion can be proved by straightforward comparison of the first five leading coefficients of these two polynomials.
For given k, j (possibly equal) we define the polynomial Q kj (x, y), equal to P k (x) − P j (y), divided by all possible linear factors.If k = j, we denote this polynomial by Q j (x, y).One can show that for k, j < p − 2 Proof.First, consider the case j = k.Recall a Theorem of Fried [7], with modification by Turnwald [18].We adopt it for the field F p and polynomial f of degree less than p: x − y If f is indecomposable, and is not equal αD n,a (x + b) + c for some α, a, b, c ∈ F p , then φ(x, y) is absolutely irreducible.
Application to the polynomial P j (along with the Lemma 6), with the explicit check for j = 3, gives the result.Now, consider the case j = k.Recall the statement of Theorem 1B in [19]: be a polynomial from K[x, y] for some field K, where g 0 is a non-zero constant.Denote and suppose ψ(f ) = m d where m is coprime to d.Then f (x, y) is absolutely irreducible.Notice that ψ(Q kj ) = k j , and therefore this gives the result.Clearly, if j > k are odd primes, Lemma 7 is applicable, and Lemmas 2, 3 imply the following: (1) (2) where I is a finite arithmetic progression in F p .

On inequality |A(p)A(p)| p + o(p)
Now we prove Theorem 1: Proof.Let ε 1 , ε 2 > 0 be dependent on p, but separated from zero.Set Let I be the set of odd numbers, not exceeding 2N − M , and let Y j := P j (I).

On inequality |A
We turn to the proof of Theorem 2.
Proof.Let I := {L + 1, . . ., L + N − M }, and X j := P j (I), j M , with parameters N, M depending on the case: Case 1: N p 13/14 (log p) 4/7 .For this case one can apply the same argument as in the proof of Theorem 1 to obtain the desired bound.
Case 3: p 7/8 log p N p 4/5 (log p) 8/5 .Let R be a positive integer we choose later.Let M be a number with exactly R odd primes below it.Clearly, M ≈ R log R. Clearly, for odd prime j below M we have Q. Clearly, summing |X k ∩ X j | for odd primes k below odd prime j M , we have Therefore, setting R := Q 1/3 (log Q) −2/3 , we obtain Case 4: p 4/5 (log p) 8/5 N p 1/2 (log p) 2 .We follow the same line of argumentation, as in the [8], but with modified bounds on sets X j and their intersections.From now on we work with all j, not just prime ones.Clearly, J(j), J(k, j) pj, and therefore estimates J N (j), J N (k, j) N 2 p 2 pj + O(j 2 √ p(log p) 2 ) hold, same as in [8].

r∈Fp|
Î(r)| p log p, where I : F p → C is interpreted as characteristic function of the set I ⊆ F p .
was to prove that A(p)A(p) contains residues with certain properties, which forces the estimate |A(p)A(p)| (41/48 + o(1))p to hold; combined with the observation|A(p)| + 1 2 |A(p)A(p)|this yields the result.We improve it to the following: