hermann on Fri, 09 Jun 2023 14:47:19 +0200


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

Re: efficient determination of smallest quadratic non-residue / t++ works, t=nextprime(t) hangs


On 2023-06-09 13:04, Bill Allombert wrote:
On Fri, Jun 09, 2023 at 11:26:25AM +0200, hermann@stamm-wilbrandt.de wrote:
...
But it is much better to use forprime
forprime(t=2,oo,if( kronecker(t, m)==-1, return(t)));
or
forprime(tt=2,oo,if( kronecker(tt, m)==-1, t=tt; break()));

2)
Is there a better way (like C/C++/Python argv) than I did to pass value of
"n" when executing a script with "gp .... < script.gp"?

Not really, but you can use environment variables.
env GPARG1="3756801695685 * 2 ^ 666669 + 1" gp < script.gp
and in your script do
n = eval(Strexpand("$GPARG1"));
to get n.

Thanks, I took the first forprime() loop.

But eval(Strexpand("$GPARG1")) resulted in warning in case environment variable is not set. Nevertheless environment variable looks much nicer, so I used "getenv()" instead:
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/pari/smallest_qnr.gp


pi@pi400-64:~ $ n="3756801695685 * 2 ^ 666669 + 1" gp -q < smallest_qnr.gp
n is 200700-digit number
  ***   last result: cpu time 1 ms, real time 1 ms.
smallest quadratic non-residue of n: 31
pi@pi400-64:~ $
pi@pi400-64:~ $ gp -q < smallest_qnr.gp
Format: n="value"  gp -q < smallest_qnr.gp
10000/36401/100355/200700/272770/330855/388342-digit number examples:
n="(10 ^ 10000 - 1) \ 3 - 10 ^ 6333"
n="34*((10^36400-1)\9)-42000040044444004000024*10^2264*((10^36400-1)\9)\((10^4550-1)\9)-1"
n="65516468355 * 2 ^ 333333 + 1"
n="3756801695685 * 2 ^ 666669 + 1"
n="1705 * 2 ^ 906110 + 1"
n="2145 * 2 ^ 1099064 + 1"
n="2996863034895 * 2 ^ 1290000 + 1"
pi@pi400-64:~ $



Regards,

Hermann Stamm-Wilbrandt.