public PrimeSet(int c) { Count = c; Primes = UtilityMath.ErathostenesSieve(3, 20000); Minimums = Enumerable.Repeat(int.MaxValue, 5).ToArray(); Pairs = new HashSet <int> [Primes.Length]; Set = new int[Count]; var IsPrime = UtilityMath.IsPrimeUsingSquares.Memoize(); for (int a = 0; a < Primes.Length; a++) { Pairs[a] = new HashSet <int>(); int x = Primes[a]; for (int b = 0; b < Primes.Length; b++) { if (a == b) { continue; } int y = Primes[b]; if (IsPrime(UtilityMath.NumericConcat(x, y)) && IsPrime(UtilityMath.NumericConcat(y, x))) { Pairs[a].Add(y); } } } }