| Karim Belabas on Wed, 27 Dec 2006 12:27:24 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: bug? |
* Bill Allombert [2006-12-22 18:32]:
> On Fri, Dec 22, 2006 at 11:12:10AM -0600, Ariel Pacetti wrote:
>> I don't know whether this is a bug or it is made on purpose, but in gp,
>> the following happens:
>>
>> ? isprime(-3)
>> %1 = 0
>
> PARI 2.1 return 1 so it is probably a bug.
Actually, when I wrote the isprime driver around Henri Cohen's APRCL
code and BPSW pseudoprimality test (both new in 2.3), I changed it on
purpose.
1) The docs say: "isprime(x): true (1) if x is a (proven) prime number".
[ In 2.1, we had "true if x is a strong pseudo-prime" ]
2) The most common definition for a prime number is "a positive integer
having exactly two divisors".
[ I don't think a function isprimeidealofZ() would be that useful.
One would include 0, also. ]
On the other hand,
(11:47) gp > isprime(-2)
%1 = 0
(11:47) gp > isprime(-2,1)
%2 = 1
(11:47) gp > ispseudoprime(-2)
%3 = 1
(11:47) gp > ispseudoprime(-2,10)
%4 = 1
%2 should definitely be 0.
%4 follows precisely the old (partly broken: the number of compositeness tests
should depend on the input size) implementation.
Arguably, %2, %3 and %4 should also be changed to return 0, for consistency.
%%%%%%%%%%%%%%
Why do you need -3 to be reported as prime ?
K.B.
--
Karim Belabas Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]