Ask Your Question

Product of primes not dividing $N$ in SAGE.

asked 2017-07-07 00:25:32 +0200

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-07 03:10:31 +0200

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 22:17:48 +0200 )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-07 00:25:32 +0200

Seen: 528 times

Last updated: Jul 07 '17