int start = 0; int step = smallSieve.sieveSearch(smallSieve.length, start); int convertedStep = (step *2) + 1; step = smallSieve.sieveSearch(smallSieve.length, step+1); convertedStep = (step *2) + 1; } while (step > 0);
int start = 0; int step = smallSieve.sieveSearch(smallSieve.length, start); int convertedStep = (step *2) + 1; step = smallSieve.sieveSearch(smallSieve.length, step+1); convertedStep = (step *2) + 1; } while (step > 0);
/** * Construct a "small sieve" with a base of 0. This constructor is * used internally to generate the set of "small primes" whose multiples * are excluded from sieves generated by the main (package private) * constructor, BitSieve(BigInteger base, int searchLen). The length * of the sieve generated by this constructor was chosen for performance; * it controls a tradeoff between how much time is spent constructing * other sieves, and how much time is wasted testing composite candidates * for primality. The length was chosen experimentally to yield good * performance. */ private BitSieve() { length = 150 * 64; bits = new long[(unitIndex(length - 1) + 1)]; // Mark 1 as composite set(0); int nextIndex = 1; int nextPrime = 3; // Find primes and remove their multiples from sieve do { sieveSingle(length, nextIndex + nextPrime, nextPrime); nextIndex = sieveSearch(length, nextIndex + 1); nextPrime = 2*nextIndex + 1; } while((nextIndex > 0) && (nextPrime < length)); }
/** * Construct a "small sieve" with a base of 0. This constructor is * used internally to generate the set of "small primes" whose multiples * are excluded from sieves generated by the main (package private) * constructor, BitSieve(BigInteger base, int searchLen). The length * of the sieve generated by this constructor was chosen for performance; * it controls a tradeoff between how much time is spent constructing * other sieves, and how much time is wasted testing composite candidates * for primality. The length was chosen experimentally to yield good * performance. */ private BitSieve() { length = 150 * 64; bits = new long[(unitIndex(length - 1) + 1)]; // Mark 1 as composite set(0); int nextIndex = 1; int nextPrime = 3; // Find primes and remove their multiples from sieve do { sieveSingle(length, nextIndex + nextPrime, nextPrime); nextIndex = sieveSearch(length, nextIndex + 1); nextPrime = 2*nextIndex + 1; } while((nextIndex > 0) && (nextPrime < length)); }