On 1/20/11 11:14 AM, Oliver Kullmann wrote:
> Hello,
>
> Maxima 5.21.1 as well as 5.23.2, built with Ecl 11.1.1,
> has a completely corrupted next_prime function, e.g.
> next_prime(113) = 121 = 11^2
> (determining all "primes" within {1,...,1000} yields 231
> "primes", while there are 168).
>
> Don't know whether this is an Ecl or a Maxima (or a joint) problem.
> Would be good to find out.
Now that everyone has verified that other lisps don't show this, how
about fixing it?
A peek at next-prime-det in src/ifactor.lisp has this bit of code:
(loop while 1 do
(dolist (p *small-primes*)
(if (= (mmod n p) 0) (return))
(if (>= (* p p) n) (return-from next-prime-det n)))
(incf n (nth (mmod n 210) deltaprimes)))
For whatever reason, ecl doesn't execute the loop. It should because
"1" is equivalent to true. When I change the 1 to T, ecl returns 127 as
the next prime.
Of course, since this is an infinite loop, we could just get rid of the
"while 1 do" part and just use plain loop.
Sounds like a bug in ecl to me.
Ray