Q:

How to apply an 'indicator' function to infinite product?

Suppose there exists an 'indicator' function whose argument is the positive integers $n$, and which yields $1$ or $0$ depending on whether $n$ is a member of some set $S$:
$$f(n):=
\begin{cases}
1,  & n\in S \\
0, & n\notin S
\end{cases}$$
I want to find the infinite product
$$\prod_{n\in S}n$$
but I want to express it in terms of all $n$ rather than pre-selecting $n\in S$, so that for some function $g$
$$\prod_{n\in S}n=\prod_{n=1}^\infty g(n)$$
Is it possible to find $g$ as a function of $f$?
If the series was a summation rather than a product it would of course be easy:
$$\sum_{n\in S}n=\sum_{n=1}^\infty f(n) n$$
But the product case appears to be much harder, and I'm wondering if I'm missing something blindingly obvious.

A:

Yes $$\prod _{n \in \mathbb N}n^{f(n)}$$

