chiark / gitweb /
math/pfilt.c (pfilt_jump): Fix off-by-one error in reduction.
Oh, dear. This is quite a bad one. The loop added the residues for the
jump to the candidate, and reduced each if the result was strictly
higher than the modulus. It then reports failure (or immediate success)
if any residue is zero, otherwise reporting a candidate for subsequent
testing. Obviously, this is a stupid bug, with the result that,
effectively, every step reports a candidate for further testing.
This bug has two bad consequences.
* Candidates with small factors aren't weeded out, so prime searching
takes an unnecessarily long time. I'd spotted this, but didn't have
a way in to investigate the problem.
* Candidates which actually have small factors, but are in fact below
the `smallenough' threshold, are reported as being verified as
prime, so the overall procedure erroneously returns known
composites.