hermann on Sat, 30 Sep 2023 14:13:25 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: primorial operator '#' for GP?


On 2023-09-30 10:44, Bill Allombert wrote:
On Wed, Sep 27, 2023 at 08:29:16AM -0400, Charles Greathouse wrote:
I would definitely use a # operator if it were added. But I don’t mind the decision to leave the operator space clean; there are a lot of use cases
for PARI/GP and clutter is a real concern.

We added # yesterday as an experiment.
I hope it will work for you!

Cheers,
Bill

Thank you! I pulled latest and built without issues.

Then I searched for a more complex use of "#" example from list
of 5000 largest primes and found quadruplet with 3× "#":

https://t5k.org/primes/lists/all.txt
----- ------------------------------- -------- ----- ---- --------------
 rank  description                     digits   who   year comment
----- ------------------------------- -------- ----- ---- --------------
...
5605c (1049713153083*2917#*(567*2917#+1)+2310)*(567*2917#-1)/210+9
                                           3753 c101  2023
          Quadruplet (4),ECPP
 5606c (1049713153083*2917#*(567*2917#+1)+2310)*(567*2917#-1)/210+7
                                           3753 c101  2023
          Quadruplet (3),ECPP
 5607c (1049713153083*2917#*(567*2917#+1)+2310)*(567*2917#-1)/210+3
                                           3753 c101  2023
          Quadruplet (2),ECPP
 5608c (1049713153083*2917#*(567*2917#+1)+2310)*(567*2917#-1)/210+1
                                           3753 c101  2023
          Quadruplet (1),ECPP
...


Just works:

$ ./gp -q
? \v
        GP/PARI CALCULATOR Version 2.16.1 (development 28704-e9753897f)
          amd64 running linux (x86-64/GMP-6.1.2 kernel) 64-bit version
            compiled: Sep 30 2023, gcc version 8.5.0 20210514 (GCC)
                            threading engine: single
                 (readline v7.0 enabled, extended help enabled)
? p=(1049713153083*2917#*(567*2917#+1)+2310)*(567*2917#-1)/210+9;
? #digits(p)
3753
? [ispseudoprime(p-d)|d<-[0,2,6,8]]
[1, 1, 1, 1]
?


I had verified that all entries matching "#" were of the form "[0-9]#"
in list of 5000 largest primes.

I looked into compiling custom readline macros to replace all "[0-9][0-9]*#" with "primorial(\1)" in current readline line and map that macro to some CTRL key combination. Good that you have implemented "#" operator, so that work
is not needed anymore.

Even better, "#" operator (of course) works in case of parenthesis preceding:

? (3*4+1)#
30030
? 13#
30030
? 2*3*5*7*11*13
30030
?


Regards,

Hermann.