diff options
| author | Paul Eggert | 2011-06-14 13:57:33 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-14 13:57:33 -0700 |
| commit | 86fe5cfe4de95a44b949db9be105e78497318804 (patch) | |
| tree | 4f2026c11792c0d544be36da5e9289010a8a04a8 /src | |
| parent | 80e88859ec7b69bb88e76e9d23c8dc16151bd836 (diff) | |
| download | emacs-86fe5cfe4de95a44b949db9be105e78497318804.tar.gz emacs-86fe5cfe4de95a44b949db9be105e78497318804.zip | |
* 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?
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/fns.c | 10 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 54fe58d1118..7bd1d47b328 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2011-06-14 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-06-14 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * fns.c (next_almost_prime): Don't return a multiple of 3 or 5. | ||
| 4 | The previous code was bogus. For example, next_almost_prime (32) | ||
| 5 | returned 39, which is undesirable as it is a multiple of 3; and | ||
| 6 | next_almost_prime (24) returned 25, which is a multiple of 5 so | ||
| 7 | why was the code bothering to check for multiples of 7? | ||
| 8 | |||
| 3 | * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, for vector length. | 9 | * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, for vector length. |
| 4 | 10 | ||
| 5 | * eval.c, doprnt.c (SIZE_MAX): Remove; inttypes.h defines this now. | 11 | * eval.c, doprnt.c (SIZE_MAX): Remove; inttypes.h defines this now. |
| @@ -3379,13 +3379,9 @@ check_hash_table (Lisp_Object obj) | |||
| 3379 | EMACS_INT | 3379 | EMACS_INT |
| 3380 | next_almost_prime (EMACS_INT n) | 3380 | next_almost_prime (EMACS_INT n) |
| 3381 | { | 3381 | { |
| 3382 | if (n % 2 == 0) | 3382 | for (n |= 1; ; n += 2) |
| 3383 | n += 1; | 3383 | if (n % 3 != 0 && n % 5 != 0 && n % 7 != 0) |
| 3384 | if (n % 3 == 0) | 3384 | return n; |
| 3385 | n += 2; | ||
| 3386 | if (n % 7 == 0) | ||
| 3387 | n += 4; | ||
| 3388 | return n; | ||
| 3389 | } | 3385 | } |
| 3390 | 3386 | ||
| 3391 | 3387 | ||