TITLE: Elementary congruences and L-functions
QUESTION [24 upvotes]: In a recent article, Emmanuel Lecouturier proves a generalization of the following surprising result: for a Mersenne prime $N = 2^p - 1 \ge 31$, the element 
$$ S = \prod_{k=1}^{\frac{N-1}2} k^k $$ 
is a $p$-th power modulo $N$, and observed that he did not know an elementary proof. Neither do I.
Numerical experiments suggest that $s_p$ is actually a $6p$-th power
modulo $N$. I can't even see why it is a quadratic residue, i.e., why
the following result (not proved in the article cited) should hold:
$$ T = \prod_{k=1}^{\frac{N+1}4} (2k-1) $$ 
is a square mod N.
For arbitrary primes $N \equiv 3 \bmod 4$, the following seems to hold: 
$$ \Big(\frac{T}{N} \Big) = \begin{cases}
    - (-1)^{(h-1)/2} & \text{ if } N \equiv  3 \bmod 16, \\
    - 1      & \text{ if } N \equiv  7 \bmod 16, \\
      (-1)^{(h-1)/2} & \text{ if } N \equiv 11 \bmod 16, \\
    + 1      & \text{ if } N \equiv 15 \bmod 16, 
\end{cases} $$
where $h$ is the class number of the complex quadratic number field with discriminant $-N$. This suggests a possible proof using L-functions (i.e. using methods in (Congruences for L-functions, Urbanowicz, K.S. Williams) and explains the difficulty of finding an elementary proof. 
My questions:

Is this congruence for $(T/N)$ known?
How would I start attacking this result using known results on L-functions?

REPLY [22 votes]: 1. First we show that
$$\left(\frac{T}{N}\right) = \begin{cases}
    - (-1)^{(h-1)/2} & \text{ if } N \equiv  3 \bmod 16, \\
      (-1)^{(h-1)/2} & \text{ if } N \equiv 11 \bmod 16. \\
\end{cases}$$
Consider the sets
$$A_0:=\{1,2,\dots,\tfrac{N-1}{2}\},\quad A_1:=\{1,3,\dots,\tfrac{N-1}{2}\},\quad A_2:=\{2,4,\dots,\tfrac{N-3}{2}\},$$
$$ A_3:=\{1,2,\dots,\tfrac{N-3}{4}\},\quad A_4:=\{\tfrac{N+1}{4},\tfrac{N+5}{4},\dots,\tfrac{N-1}{2}\}.$$
Consider also the corresponding character sums
$$S_i:=\sum_{a\in A_i}\left(\frac{a}{N}\right),\qquad i=0,1,2,3,4.$$
Modulo $N$, we have $2A_3=A_2$ and $-2A_4=A_1$. Therefore, $S_3=-S_2$ and $S_4=S_1$, and hence $S_1-S_2=S_3+S_4=S_0$. But also $S_1+S_2=S_0$, hence $S_1=S_0$ and $S_2=0$. On the other hand, it is known that $S_0=3h$, see e.g. Theorem 70 in Fröhlich-Taylor: Algebraic number theory. This means that $S_1=3h$, i.e. the number of quadratic nonresidues in $A_1$ equals
$$ n=\frac{N+1}{8}-\frac{3h}{2}=\frac{N+5}{8}-2h+\frac{h-1}{2}.$$
We conclude
$$ \left(\frac{T}{N}\right)=(-1)^n=(-1)^{(N+5)/8}(-1)^{(h-1)/2}. $$
This is the claimed formula (with Jeremy Rouse's correction).
2. Now we show that
$$\left(\frac{T}{N}\right) = \begin{cases}
    - 1      & \text{ if } N \equiv  7 \bmod 16, \\
    + 1      & \text{ if } N \equiv 15 \bmod 16.
\end{cases}$$
We proceed as before, but this time we get $S_3=S_2$ and $S_4=-S_1$, so that $S_2-S_1=S_3+S_4=S_0$. Together with $S_2+S_1=S_0$, this yields $S_1=0$ and $S_2=S_0$. Hence the formula for $n$ simplifies to $n=(N+1)/8$, and we conclude
$$\left(\frac{T}{N}\right)=(-1)^n=(-1)^{(N+1)/8}.$$