Package com.uwyn.jhighlight.pcj.hash
Class Primes
- java.lang.Object
-
- com.uwyn.jhighlight.pcj.hash.Primes
-
public class Primes extends Object
This class provides a static table of int sized prime numbers. For small numbers (0-511) it contains all primes. For larger numbers it contains 32 primes each time the number of bits is increased. I.e., there are 32 primes from 512 to 1023, 32 primes from 1024 to 2048, etc., the primes thus becoming less dense with size. Within the interval formed by using one more bit (say, v0 to v1), the 32 primes are formed by searching for the first prime greater than or equal to v0 + n*(v1-v0)/32, n belonging to {0,1,2, ..., 31}. This creates a reasonable distribution.- Since:
- 1.0
- Version:
- 1.2 21-08-2003 20:21
- Author:
- Søren Bak
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
nextPrime(int n)
Returns from a static prime table the least prime that is greater than or equal to a specified value.
-
-
-
Method Detail
-
nextPrime
public static int nextPrime(int n)
Returns from a static prime table the least prime that is greater than or equal to a specified value. On average, the returned prime will about 1/64 of 2(r+1) - 2r greater than n, where r is the order of n (the number of bits required for representing it).- Returns:
- the least prime in the table that is greater than or equal to the specified value.
-
-