Beispiel #1
0
        public List <PrimeTuple> GetTwoTuplesList(List <long> primeList)
        {
            var primeTuples = new List <PrimeTuple>();

            for (int i = 0; i < primeList.Count; i++)
            {
                for (int j = 0; j < primeList.Count; j++)
                {
                    var primeTuple = new PrimeTuple {
                        First = primeList[i], Second = primeList[j]
                    };
                    if (!primeTuple.IsTwoPrimeTuple())
                    {
                        continue;
                    }
                    if (primeTuples.Count(pt => pt.First == primeTuple.Second && pt.Second == primeTuple.First) < 1)
                    {
                        primeTuples.Add(primeTuple);
                    }
                }
            }
            return(primeTuples.OrderBy(pt => pt.Sum).ToList());
        }
Beispiel #2
0
        public List <PrimeTuple> GetFourTuplesList(List <PrimeTuple> threeTuples, List <long> primeList)
        {
            var primeTuples = new List <PrimeTuple>();

            foreach (var threeTuple in threeTuples)
            {
                for (int i = 0; i < primeList.Count; i++)
                {
                    if (primeList[i] <= threeTuple.Max)
                    {
                        continue;
                    }
                    var primeTuple = new PrimeTuple {
                        First = threeTuple.First, Second = threeTuple.Second, Third = threeTuple.Third, Fourth = primeList[i]
                    };
                    if (!primeTuple.IsFourPrimeTuple())
                    {
                        continue;
                    }
                    primeTuples.Add(primeTuple);
                }
            }
            return(primeTuples.OrderBy(pt => pt.Sum).ToList());
        }