[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
factor and primes
From: |
Eric Kelm |
Subject: |
factor and primes |
Date: |
Wed, 26 Mar 2003 18:58:29 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Win98; de-AT; rv:1.3) Gecko/20030312 |
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?
--- 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- factor and primes,
Eric Kelm <=