All the descriptions of the sieve of Eratosthenes that I have seen speak of crossing out multiples of p, for p=2,3,5, etc. But there is an obvious easy optimization for p>2 : The even multiples of p would have been already crossed out, so you need only cross out the odd multiples. (You can also avoid multiples of the form m*p where q divides m for q<p, but at that point it starts to be a different algorithm.)
______________________________________ From: Roger Hui <[email protected]> Date: Fri Jun 4 13:31:22 HKT 2010 Subject: [Jprogramming] odd multiples j, m, and n are positive integers with m<n. Find a neat expression for all the odd multiples of j in [m,n), that is, all k such that (m<:k)*.(k<n)*.(1=2|k%j) . ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
