mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   summation in pari gp (https://www.mersenneforum.org/showthread.php?t=28002)

 Adrian 2022-08-12 07:51

summation in pari gp

Is there any command to evaluate in PARI GP such sum: $$\sum\limits_{\substack{2\leq d\leq n \\ (d, n)=1}}\frac{a\left(n\right)}{d}$$?

In other words: how to add to command

sum(d=2, n, \frac{a(n)}{d})

condition from second line $(d,n)=1$) (or more such conditions)

 LaurV 2022-08-12 09:48

you mean this?

[CODE]gp > sum(d=1,20,if(d%2==0&&d%3==0,1./d,0),0)
%1 = 0.30555555555555555555555555555555555556
gp > 1./6+1/12+1/18
%2 = 0.30555555555555555555555555555555555556
gp >[/CODE]
Pari is a programing language, how you combine the stuff is up to you :razz:
(p.s. I also edited your post and fixed your formula)

 All times are UTC. The time now is 01:25.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.