Bill Allombert on Mon, 11 Jun 2012 14:45:19 +0200


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

Re: Set prime limit


On Mon, Jun 11, 2012 at 02:25:35PM +0200, Jean-Marie Madiot wrote:
> Dear all,
> 
> I know that I can set GP stack size both when launching gp and at runtime:
> 
>   $ gp -s 12345678
>   ? allocatemem(12345678)

You can also do

default(parisize,12345678)

> I don't know if it's a good idea, but it's quite handy.
> 
> 1) Is it possible to do the same for the prime limit (i.e. to run the
> sieve at runtime)?

Yes, use
default(primelimit,12345678)

> 2) Is it possible to access the prime limit at runtime?

default(primelimit)

> 3) Is it possible to access the stack size at runtime? (this is just
> by curiosity though)

default(parisize)

> 4) Would it be possible to have a forprime() function that goes beyond
> the prime limit?

We added this feature in the development branch, so now you can do:
? forprime(p=2^100,,if(p%123==1,return(p)))
%2 = 1267650600228229401496703208451

> I have workaround that does (4), but I need to enter the prime limit
> manually (then beyond the prime limit uses the slower isprime())

It is advised to use nextprime instead of isprime for this purpose, this is
slightly faster.

Cheers,
Bill.