Sifting function (source code)

= Sifting function
{title2=$S(A,\mathcal P,z)$}

For a finite set $A$ of <positive integers> and a set of <prime numbers> $\mathcal P$, the <sifting function> counts elements divisible by no <prime number> in $\mathcal P$ strictly below $z$:
$$
P(z)=\prod_{\substack{p\in\mathcal P\\p<z}}p,\qquad S(A,\mathcal P,z)=\#\{a\in A:\gcd(a,P(z))=1\}.
$$
The strict inequality is the endpoint convention used in the <Buchstab identity> here. With an empty product, $P(z)=1$ and every element survives.

For a finitely supported nonnegative weighted <sequence> $\mathcal A=(a_n)$, use the same notation for $S(\mathcal A,\mathcal P,z)=\sum_{\gcd(n,P(z))=1}a_n$. Choosing $a_n$ to be the <indicator function> of $A$ recovers the set version. For $A=\{1,\ldots,10\}$, all <prime numbers> allowed, and $z=5$, only $2$ and $3$ are removed as divisors, leaving $1,5,7$ and giving $S=3$.