Assume that there exists an integer k such that 0≤k≤p2 and p2 divides k(k+1)(k+2)⋯(k+p−3)−1. Because p does not divide any of the p−2 consecutive integers k,(k+1),(k+2),…,(k+p−3), either k≡1 or 2modp. If k≡2modp then, by Wilson's theorem,
k(k+1)(k+2)⋯(k+p−3)−1≡(p−1)!−1≡−2≡0modp.
We deduce that k≡1modp.
On the other hand, we know from Wilson's theorem that (p−2)!−1≡0modp. This means that there exists a unique integer i0∈{1,…,p} such that
(p−2)!−1≡i0pmodp2.
Let k=ip+1 for some integer i∈{0,1,…,p−1}. We have
k(k+1)(k+2)⋯(k+p−3)−1≡(ip+1)(ip+2)⋯(ip+p−2)−1≡(p−2)!−1+ipj=1∑p−2j(p−2)!modp2
and
j=1∑p−2j(p−2)!≡(p−2)!j=1∑p−2j−1≡j=1∑p−2j≡2(p−2)(p−1)≡1modp
We deduce that
k(k+1)(k+2)⋯(k+p−3)−1≡(i0+i)pmodp2.
This proves that k(k+1)(k+2)⋯(k+p−3)−1≡0modp2 only for k=(p−i0)p+1.