While verifying the claim of another post, I found experimental evidences suggesting the curious formula relating $\pi$ and primes. Let $P$ be the set of prime and $p \in P$. I observed that $$ \frac{\pi}{4} = \prod_{p \equiv 1 \bmod 4} \frac{p}{p-1} \prod_{p \equiv 3 \bmod 4} \frac{p}{p+1} \tag 1 $$
where the products run over the set of all primes. User @Lukas Heger commented that the above identify is indeed true and is Euler product for the L-function attached to the unique primitive Dirichlet character of modulus $4$. Later I found in Wikipedia that this was a classical result due to Euler himself. Define
$$ f(n) = \prod_{r < n \atop p \in P} \left(\prod_{p \equiv r \bmod 2n} \frac{p}{p-1}\right) \cdot \prod_{r > n \atop p \in P} \left(\prod_{p \equiv r \bmod 2n} \frac{p}{p+1}\right).\tag 2 $$
where the product is taken over all primes $p$. Then Euler's formula can be expressed as $\displaystyle f(2) = \frac{\pi}{4}$. The same Wikipedia article also gives $\displaystyle f(3) = \frac{\sqrt{3}\pi}{6}$. Upon further explorations, I found a few more possible identities based on computation up to the first $6.4 \times 10^9$ primes, with the results agreeing up to five or more decimal places. The data shows that
$$ f(4) = \frac{\pi}{\sqrt{2}}, \text{ } f(6) = \pi, \text{ } f(10) = \frac{\sqrt{5}\pi}{2} $$
However $f(5)$ and $f(8)$ does not seem to have a closed form expression.
Question 1: For what $n$ does $f(n)$ has a closed form expression and what is this closed form?
Moreover for the same value of $n$, alternating the $\pm$ in the denominators produces other algebraic multiples of $\pi$. For example, for $n=6$
$$ \frac{\pi}{3} = \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p+1} \tag 3 $$
$$ \frac{\pi}{3} = \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p-1} \tag 4 $$
$$ \frac{\pi}{2\sqrt{3}} = \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p+1} \tag 5 $$
$$ \frac{2\pi}{3\sqrt{3}} = \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p-1} \tag 6 $$
Trivially when we change the order, there must be a equal number of terms with $p-1$ and $p+1$ in the denominators otherwise the product will diverge to infinity or converge to zero. I observed, in case of non-alternative orders, $$ \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p-1} \tag 7 $$ and $$ \prod_{p \equiv 1 \bmod 12 \atop p \in P} \frac{p}{p+1} \prod_{p \equiv 5 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 7 \bmod 12 \atop p \in P} \frac{p}{p-1} \prod_{p \equiv 11 \bmod 12 \atop p \in P} \frac{p}{p+1} \tag 8 $$ do not seem to have such a closed form.
Question 2: For what order of the terms $p-1$ and $p+1$ in the denominators does such a closed form exist?