public static int GetPrime(int min) { if (min < 0) { throw new ArgumentException(); } System.Diagnostics.Contracts.Contract.EndContractBlock(); for (int i = 0; i < HashHelpers.primes.Length; i++) { int prime = HashHelpers.primes[i]; if (prime >= min) { return(prime); } } //outside of our predefined table. //compute the hard way. for (int i = (min | 1); i < Int32.MaxValue; i += 2) { if (HashHelpers.IsPrime(i) && ((i - 1) % HashHelpers.HashPrime != 0)) { return(i); } } return(min); }
internal static int GetPrime(int min) { if (min < 0) { throw new FMException("prime value is zero!"); } for (int i = 0; i < HashHelpers.primes.Length; i++) { int num = HashHelpers.primes[i]; if (num >= min) { return(num); } } for (int j = min | 1; j < 2147483647; j += 2) { if (HashHelpers.IsPrime(j)) { return(j); } } return(min); }