protected override void Generate()
        {
            Sequence sexy = new SexyPrime(Max + 8);
            Sequence twin = new TwinPrime(Max + 8);

            int prevPrevPrevTerm = 0;
            int prevPrevTerm     = 0;
            int prevTerm         = 0;

            foreach (int prime in sexy.Numbers)
            {
                if (prime > Max)
                {
                    break;
                }
                if (sexy.Contains(prime + 6))
                {
                    if (twin.Contains(prime + 2) && twin.Contains(prime + 8))
                    {
                        AddNumber(prime, prevPrevTerm, prevTerm);
                        AddNumber(prime + 2, prevPrevTerm, prevTerm);
                        AddNumber(prime + 6, prevPrevTerm, prevTerm);
                        AddNumber(prime + 8, prevPrevTerm, prevTerm);
                        prevPrevPrevTerm = prime + 2;
                        prevPrevTerm     = prime + 6;
                        prevTerm         = prime + 8;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public IsolatedPrime(int max)
        {
            Sequence   primes     = new SieveOfEratosthenes(max);
            Sequence   twinPrimes = new TwinPrime(max);
            Difference difference = primes.Difference(twinPrimes);

            saveToFolder = "Prime_Isolated";
            Max          = difference.Max;
            Numbers      = difference.Numbers;
        }