I did not! Perfect :)
Thank you!
Ash
On 11 Dec 2020, at 12:06, Denis Simon <denis.simon@unicaen.fr> wrote:
did you try vecsum in gp ?
Denis.
De: "Brereton, Ashley" <mf0u6084@liverpool.ac.uk>
À: "Bill Allombert" <Bill.Allombert@math.u-bordeaux.fr>, "pari-users" <pari-users@pari.math.u-bordeaux.fr>
Envoyé: Vendredi 11 Décembre 2020 18:01:52
Objet: Re: Sum over prime numbers function
I tried this and it's a smidge faster than prodeuler and I was hoping it would be much faster. Is there a vectorised way I can do this instead? e.g.
sum (primes(n))
I can't seem to find a way to sum a vector of values.
Thanks for your help!
Ash
From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
Sent: Friday, December 11, 2020 2:48 AM
To: pari-users@pari.math.u-bordeaux.fr <pari-users@pari.math.u-bordeaux.fr>
Subject: Re: Sum over prime numbers function
On Fri, Dec 11, 2020 at 01:55:30AM +0000, Brereton, Ashley wrote:
> Hi all,
>
> I wondered if there was a handy function to sum over only the prime
> numbers? Like a sum version of prodeuler.
No. Instead you can use forprime:
my(s=0);forprime(p=2,100,s+=f(p));s
Cheers,
Bill.
|