Can Mathematica Sum or Multiply over the set of all primes?

I can get an estimate of my question in the title with:

Product[1 + 1/p^2, {p, Prime[Range[1000]]}] // N

Can Mathematica return the exact value?

Answer of Wolfgang

I place my answer here, as it was not given in the reference quoted and there is no other entry space.

The answer in your case is yes: simply write down what you want

Product[1 + 1/Prime[k]^s, {k, 1, \[Infinity]}]

(* Out[2]= Zeta[s]/Zeta[2 s] *)

And, specifically, for s = 2 we have


Out[154]= 15/\[Pi]^2

% // N

Out[153]= 1.51982

Your Approximation

Product[1 + 1/p^2, {p, Prime[Range[1000]]}] // N

Out[146]= 1.5198

is close to the exact value.

If you wish, you can prove the formula for the product analytically.


$\eta (s)=\prod _{p} \left(1+\frac{1}{p^s}\right)$

and consider the Riemann zeta function Zeta[s], defined by

$\zeta (s)=\prod _p \frac{1}{1-\frac{1}{p^s}}$


$\frac{\eta (s)}{\zeta (s)}=\prod _p \left(1+\frac{1}{p^s}\right) \left(1-\frac{1}{p^s}\right)=\prod _p \left(1-\frac{1}{p^{2 s}}\right)=\frac{1}{\zeta (2 s)}$


$\eta (s)=\frac{\zeta (s)}{\zeta (2 s)}$

  • $\begingroup$ I don't see where this question was answered before, therefore I did it here. But I would prefer to put it in an answer instead of an edit. Can somebody of the "marking crew" either explain where exactly I can find the previous question and answer, or otherwise reopen the question? Thanks. $\endgroup$ – Dr. Wolfgang Hintze Feb 16 '15 at 15:26
  • $\begingroup$ Yes, Thank you Dr. Wolfgang Hintze. Also, since every positive integer can be uniquely factored into a perfect square and a square free integer we can translate directly to a Dirichlet generating function: zeta(s) = zeta(2*s)*mu^2(s). $\endgroup$ – Geoffrey Critzer Feb 28 '15 at 23:13

Browse other questions tagged or ask your own question.