primep matter



Andrei Zorine <zoav1@uic.nnov.ru> writes:

> 1) primep(2^31-1) hangs.

Not on SBCL or CLISP.

> 2) (defun primep...) tries to factor its argument which is very slow.

Only if a pseudo-prime test (in a weak sense) is passed.  In the worst
case (if the argument N is actually a prime) CFACTOR performs
sqrt(N)/3+O(1) trial divisions.  There was a similar discussion some
time ago in the thread starting with

http://www.math.utexas.edu/pipermail/maxima/2002/001979.html

But I think that Camm fixed that (GCL-) bug.

> 3) faster algorithhm is easily introducible: just load primeq.lisp from
> Prof. Fateman's MockMathematica, and add (define jacobi-symbol(p q)
> (JacobiSymbol p q)) line.

Maxima has $JACOBI.

Wolfgang