Ariel Pacetti on Fri, 29 Dec 2006 00:37:09 +0100

 Re: bug?

```
```
I guess that the name should suggest the right answer. The help for the isprime routine gives:
```
```
isprime(x,{flag=0}): true(1) if x is a (proven) prime number, false(0) if not. If flag is 0 or omitted, use a combination of algorithms. If flag is 1, the
```primality is certified by the Pocklington-Lehmer Test. If flag is 2, the
primality is certified using the APRCL test.

```
Hence the documentation should be changed and should say "is a (proven) positive prime number". By deffinition -3 is a prime number (I don't agree with the definition that prime numbers are positive, this has no generalization to number fields). In my particular case, now that I know how the routine works makes no difference (I made a loop with negative numbers, and needed to check whether the input was prime or not, hence adding and abs() does the trick), but since this was part of another routine it took me some time to find out what was going on (also in older versions of gp, isprime(-3) answers 1). I think that the names should be consistent with the output (ispositiveprime?).
```Bests,

Ariel

On Wed, 27 Dec 2006, Karim Belabas wrote:

```
```* 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]

```
```
```

• Follow-Ups:
• Re: bug?
• From: Karim Belabas <Karim.Belabas@math.u-bordeaux1.fr>
• References:
• bug?
• From: Ariel Pacetti <apacetti@math.utexas.edu>
• Re: bug?
• From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
• Re: bug?
• From: "Karim Belabas" <Karim.Belabas@math.u-bordeaux1.fr>