Commit 86fe5cfe authored by Paul Eggert's avatar Paul Eggert

* fns.c (next_almost_prime): Don't return a multiple of 3 or 5.

The previous code was bogus.  For example, next_almost_prime (32)
returned 39, which is undesirable as it is a multiple of 3; and
next_almost_prime (24) returned 25, which is a multiple of 5 so
why was the code bothering to check for multiples of 7?
parent 80e88859
2011-06-14 Paul Eggert <eggert@cs.ucla.edu>
* fns.c (next_almost_prime): Don't return a multiple of 3 or 5.
The previous code was bogus. For example, next_almost_prime (32)
returned 39, which is undesirable as it is a multiple of 3; and
next_almost_prime (24) returned 25, which is a multiple of 5 so
why was the code bothering to check for multiples of 7?
* bytecode.c (exec_byte_code): Use ptrdiff_t, not int, for vector length.
* eval.c, doprnt.c (SIZE_MAX): Remove; inttypes.h defines this now.
......
......@@ -3379,13 +3379,9 @@ check_hash_table (Lisp_Object obj)
EMACS_INT
next_almost_prime (EMACS_INT n)
{
if (n % 2 == 0)
n += 1;
if (n % 3 == 0)
n += 2;
if (n % 7 == 0)
n += 4;
return n;
for (n |= 1; ; n += 2)
if (n % 3 != 0 && n % 5 != 0 && n % 7 != 0)
return n;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment