Let $p > 3$ be a prime number, and $\zeta$ be a primitive $p$-th root of unity. I am interested in knowing the exact value of
$$w\_p = \prod\_{a \in (\mathbb F\_p^{\times})^2}(1 + \zeta^a) + \prod\_{b \in \mathbb F\_p^{\times} \backslash (\mathbb F\_p^{\times})^2}(1 + \zeta^b). $$
(The term $w\_p$ is related to the number of subsets $S \subset \mathbb F\_p$ for which $\sum\_{s \in S} s^2 = 0.$) 


It is more or less straightforward to prove that $w\_p = 2$ for $p \equiv \pm 1 \ (\text{mod}. 8)$ and $w\_p = -2$ for $p \equiv 3 \ (\text{mod}. 8).$ 


(If anyone wants to see a proof for that, I can provide it. It boils down to the fact that $2 \in (\mathbb F\_p^{\times})^2$ in the first case and $-1 \not\in (\mathbb F\_p^{\times})^2$ in the scond case.)


So it remains to evealuate $w\_p$ for $p \equiv 5 \ (\text{mod}. 8)$. One might conjecture that in this case, we also have $w\_p = -2$, but this is wrong: The values for $p = 5,13,29,37$ are $w\_p = 3,11,27,146$. 


Indeed, it is easy to show that also in this case $w\_p$ is an integer and $w\_p \equiv -2 \ (\text{mod}. p)$. Looking at the values for small $p$, I arrived at the following conjecture:


Suppose $p \equiv 5 \ (\text{mod}. 8)$. Let $(\alpha,\beta)$ be the fundamental positive solution of the generalized Pell equation $\alpha^2 - p \beta^2 = 4$. Then $w\_p = \alpha$.


Can anyone tell me if this statement is true?



Evaluating a remarkable term for primes p = 5 (mod. 8)
According to Theorem 5.1 of
<http://math.mit.edu/~rstan/pubs/pubfiles/35.pdf>, the number is
 $$ \frac 1p\left[ 2^{p-1}+\frac{p-1}{2}(\epsilon^{4h} +
 \epsilon^{-4h})\right], $$
where $h$ is the class number of $\mathbb{Q}(\sqrt{p})$ and
$\epsilon>1$ the fundamental unit of $\mathbb{Q}(\sqrt{p})$.


**Addendum.** I should clarify that the number above is the 
number of subsets $S$ of $\mathbb{F}\_p^\*$ satisfying 
$\sum\_{s\in S}s^2=0$. To get the number of such subsets of 
$\mathbb{F}\_p$, multiply by two.


