Last update May 31, 2004
etc.prime
- bool isPrime(uint n)
- Returns true if n is prime, false otherwise. Note that this function
uses a fast lookup table for values of n less than or equal to 0xFFFF, and
trial division for numbers greater than this.
- uint getPrimeLess(uint n)
- Returns the greatest prime which is less than n. This function will
assert if n is zero, one or two.
- uint getPrimeLessEqual(uint n)
- Returns the greatest prime which is less than or equal to n. This function will
assert if n is zero or one.
- uint getPrimeGreater(uint n)
- Returns the smallest prime which is greater than n. This function will
assert if the result would be too large to fit into a uint.
- uint getPrimeGreaterEqual(uint n)
- Returns the smallest prime which is greater than or equal to n. This function will
assert if the result would be too large to fit into a uint.
To do (future work)
- For numbers between 0x10000 and 0xFFFFFFFF, there are faster algorithms than trial
division. We should probably use one.
- The remaining functions should probably throw exceptions instead of asserting.
Copyright (c) 2004 by Arcane Jill. All Rights Reserved