Gerhard Niklasch on Tue, 31 Mar 1998 23:17:00 +0200

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

A prime question, and a prime remark

[glancing at the clock before hitting the send key --
 no, it's not yet April 1.  Good.]

(1) Hear all ye PARI old-timers...

|| Is there any particular reason why isprime(-1) returns 1 in the   ||
|| 2.0 versions, or is this just a coding accident which nobody else ||
|| has noticed yet?                                                  ||

(It didn't in 1.39.)

If this is intentional, then it will need to be documented.  In all
other cases, isprime() detects genuine prime elements of the ring Z,
regardless of sign.  (Or rather, if you want to be pedantic, genuine
irreducibles. ;^)

(Note that integer factorization does not depend on this at all;
it will extract the sign regardless of what isprime(-1) returns.)

(2) The function sisprime()  (an internal tool for factorization,
in src/basemath/arith2.c)  is theoretically capable of vanishing
into bit nirvana if the primelimit is too low.

This is unlikely to hurt you unless you've made a real effort at
pretending to be stupid  (i.e. by calling factor() from gp on some
mindbogglingly huge number without imposing a limit, after having
set the primelimit to way less than 2^16),  and even then it won't
happen except in rare circumstances, but it's still ugly.

Nonetheless I'm not including a fix here since I've started playing
with other possible changes in this area which, among other things,
would offer a cleaner solution than I could contrive now.  (Along the
lines of, `there's no excuse for _not_ looking up odd numbers < 2^16
in a bitvector table to find the primes among them, given that the
table fits into a single 4KBy memory page'...)

Cheers, Gerhard