factor and primes
[email protected] (Eric Kelm) Wed, 26 Mar 2003 18:58:29 +0100
| Newsgroups | gmane.comp.gnu.sh-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi, I found a small 'bug' in factor.c. It's not really a bug, it just could be done better. Explanation: factor should return no factors if n = 0 or n = 1, so I would suggest changing if (n < 1) to if (n < 2) see factor.dif The real reason for this mail is the primes program. In the TODO file I found that it still has to be written. I would like to provide one and to put it under the GPL. But I have a few questions. What should the primes program exactly do? Print all the primes <= n? Or print all the primes between two integers? Print pi(x)? btw. pi(x) is the number of primes <= x, in case you don't know. What is meant by "gmp" in TODO: "- write (or find version that we can copyleft) primes, using gmp"? Will it be important to use a small amount of memory? _______________________________________________ Bug-sh-utils mailing list [email protected] http://mail.gnu.org/mailman/listinfo/bug-sh-utils
factor.dif
(text/plain, 331 B)
--- src/factor.c Tue Jul 2 07:21:02 2002
+++ projekte/factor.c Tue Mar 25 16:49:14 2003
@@ -101,7 +101,7 @@ factor (uintmax_t n0, int max_n_factors,
int n_factors = 0;
unsigned int const *w = wheel_tab;
- if (n < 1)
+ if (n < 2)
return n_factors;
/* The exit condition in the following loop is correct because