Ask Your Question

Product of primes not dividing $N$ in SAGE.

asked 2017-07-06 17:25:32 -0600

Manoj gravatar image

Hi, for a given $N,$ I want to compute a product of the type in SageMath

$$ \prod_{p\nmid N} \left(1-\frac{1}{p}\right)\left(1+\frac{1}{p}^{-1}\right) $$

For this I need to generate a list of these primes which does not divide $N.$ I do not know any method or command which does that. How can I compute this in sage? Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-07-06 20:10:31 -0600

kcrisman gravatar image

This is a bit ill-defined - the infinitely many such primes? But here is something you can probably modify.

sage: N = 123
sage: prod(1/p for p in set(primes(N)).difference(set(N.prime_factors())))
edit flag offensive delete link more


Thank you ver much.

Manoj gravatar imageManoj ( 2017-07-07 15:17:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-07-06 17:25:32 -0600

Seen: 122 times

Last updated: Jul 06 '17