Proof Clearly, if n satisfies the required property, then 1≤n≤p−1. Denote all such n's by n1<n2<⋯<nk; we shall show that k≤12p32. If k≤12 there is nothing to prove. In what follows, we assume that k>12.
Rename ni+1−ni (1≤i≤k−1) in nondecreasing order as
1≤μ1≤μ2≤⋯≤μk−1. It is clear that
i=1∑k−1μi=i=1∑k(ni+1−ni)=nk−n1<p.1◯
First, we show that for any s≥1,
∣{1≤i≤k−1:μi=s}∣≤s,2◯
i.e. there are at most s μi's equal to s.
In fact, suppose that ni+1−ni=s; then ni!+1≡ni+1!+1≡0(modp), so (p,ni!)=1, and
(ni+s)(ni+s−1)⋯(ni+1)≡1(modp).
Thus, ni is a solution to the congruence equation
(x+s)(x+s−1)⋯(x+1)≡1(modp).
Since p is a prime number, there are at most s solutions to the above equation, thanks to Lagrange's theorem. Thus, there are at most s ni's with ni+1−ni=s, i.e. ② holds.
Now, we show that for any nonnegative integer l, if 2l(l+1)+1≤k−1, then μ2l(l+1)+1≥l+1. Suppose on the contrary that μ2l(l+1)+1≤l. Then μ1,μ2,…,μ2l(l+1)+1 are all positive integers between 1 and l. By ②, there is at most one μi equal to 1, at most two μi's equal to 2, …, at most l μi's equal to l, and thus there are at most 1+2+⋯+l=2l(l+1) μi's less than or equal to l, which contradicts the assumption that μ1,μ2,…,μ2l(l+1)+1 are all less than or equal to l.
Let m be the largest positive integer with 2m(m+1)+1≤k−1. Then
2m(m+1)+1≤k−1<2(m+1)(m+2)+1,③
and hence
i=1∑k−1μi≥i=0∑m−1(i+1)2=6m(m+1)(2m+1)>3m3.
Since k>12, m≥4, combining ① and ③ we get
k<2+2(m+1)(m+2)<4m2+4(3i=1∑k−1μi)32<4×(3p)32.
This completes our proof.