Skip to main content
added 15 characters in body
Source Link

I'd like to take a product ofevaluate

1-1/p

$$\prod_p\left(1-\frac1p\right)$$

over the $k$ largest previous primes $\le n/2$$p\le n/2$, where $n$ is the parameter. E.g., if $n=20$ and $k$=3$k=3$, I'd like the product to be over the 3 previous primes less than or equal to $20/2=10$: namely, $7,5,3$.

The code for the previous prime is

PreviousPrime[n_Integer] := Block[{i = n}, While[! PrimeQ[-i]]; i]
SetAttributes[PreviousPrime, Listable];

How can I take a product over $k$ previous primes?

I'd like to take a product of

1-1/p

over the $k$ largest previous primes $\le n/2$, where $n$ is the parameter. E.g., if $n=20$ and $k$=3, I'd like the product to be over the 3 previous primes less than or equal to $20/2=10$: namely, $7,5,3$.

The code for the previous prime is

PreviousPrime[n_Integer] := Block[{i = n}, While[! PrimeQ[-i]]; i]
SetAttributes[PreviousPrime, Listable];

How can I take a product over $k$ previous primes?

I'd like to evaluate

$$\prod_p\left(1-\frac1p\right)$$

over the $k$ largest previous primes $p\le n/2$, where $n$ is the parameter. E.g., if $n=20$ and $k=3$, I'd like the product to be over the 3 previous primes less than or equal to $20/2=10$: namely, $7,5,3$.

The code for the previous prime is

PreviousPrime[n_Integer] := Block[{i = n}, While[! PrimeQ[-i]]; i]
SetAttributes[PreviousPrime, Listable];

How can I take a product over $k$ previous primes?

edited tags
Link
Source Link

Product over several previous primes

I'd like to take a product of

1-1/p

over the $k$ largest previous primes $\le n/2$, where $n$ is the parameter. E.g., if $n=20$ and $k$=3, I'd like the product to be over the 3 previous primes less than or equal to $20/2=10$: namely, $7,5,3$.

The code for the previous prime is

PreviousPrime[n_Integer] := Block[{i = n}, While[! PrimeQ[-i]]; i]
SetAttributes[PreviousPrime, Listable];

How can I take a product over $k$ previous primes?