Re: primorial operator '#' for GP?

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <ZRFAHJv3mCyktokN@seventeen>
On Mon, Sep 25, 2023 at 06:22:02AM +0200, [email protected] wrote:
> GP has factorial operator:
> ? 11!
> %6 = 39916800
> ?
> 
> Similarly primorial is product of first n primes.
> 
> prodeuler produces only a floating point approximation:
> ? prodeuler(p=2,11,p)
> %7 = 2310.0000000000000000000000000000000000
> ?

Better do

? vecprod(primes([1,11]))
%1 = 2310

> Something like this is exact:
> ? P(x)={r=1;forprime(p=2,x,r*=p);r}
> %8 = (x)->r=1;forprime(p=2,x,r*=p);r
> ? P(11)
> %9 = 2310
> ?
> 
> Any chance to see "#" as operator in GP like "!"?
> ? 11#
>   ***   syntax error, unexpected '#', expecting end of file: 11#
>   ***                                                          ^-

I suppose we could add a primorial() function but adding a new operator would
be a bit too much.

Cheers,
Bill.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.