public static int NumberOfPrimeUnder(int number) { int result = 0; for (int i = 2; i <= number; i++) { if (FunctionsMath.IsPrime(i)) { result++; } } return(result); }
public static List <int> GetPrimesBefore(int number) { List <int> result = new List <int>(); for (int i = 2; i <= number; i++) { if (FunctionsMath.IsPrime(i)) { result.Add(i); } } return(result); }
public static bool IsTwinPrime(int number) { if (number < 2) { return(false); } if (number == 2) { return(true); } return(FunctionsMath.IsPrime(number) && FunctionsMath.IsPrime(number + 2)); }
public static Dictionary <int, int> NumberOfPrimesByHundred(int number) { Dictionary <int, int> result = new Dictionary <int, int>(); for (int i = 2; i <= number; i++) { if (FunctionsMath.IsPrime(i)) { int index = (Math.Abs(i / 100) + 1) * 100; if (result.ContainsKey(index)) { result[index]++; } else { result.Add(index, 1); } } } return(result); }