예제 #1
0
        public static int CirculuarPrimes(int n)
        {
            PrimeFunctions.GeneratePrimesTillNToList(1000000);
            PrimeFunctions.ConvertToHash();

            int count = 0;

            for (int i = 2; i < n; i++)
            {
                List <int> rots  = CombinatoricFunctions.rotations(i);
                bool       prime = true;
                foreach (int rot in rots)
                {
                    if (!PrimeFunctions.PrimeListHash.Contains(rot))
                    {
                        prime = false;
                        break;
                    }
                }
                if (prime)
                {
                    count++;
                    //Console.WriteLine(i);
                }
            }
            return(count);
        }
예제 #2
0
        public static int truncatableprimes(int n)
        {
            int count = 0;
            int sum   = 0;

            PrimeFunctions.GeneratePrimesToList(1000000);
            PrimeFunctions.ConvertToHash();
            int i = 4;

            while (count < n)
            {
                bool       isprime = true;
                List <int> trunc   = CombinatoricFunctions.truncations(PrimeFunctions.PrimeList[i]);
                foreach (int truncation in trunc)
                {
                    if (!PrimeFunctions.PrimeListHash.Contains(truncation))
                    {
                        isprime = false;
                        break;
                    }
                }
                if (isprime)
                {
                    count++;
                    sum += PrimeFunctions.PrimeList[i];
                }
                i++;
            }
            return(sum);
        }
예제 #3
0
        public static int QuadraticPrimes(int n)
        {
            PrimeFunctions.GeneratePrimesTillNToList(n * n);
            PrimeFunctions.ConvertToHash();
            int maxi      = 0;
            int maxj      = 0;
            int maxprimes = 0;

            for (int i = (n * -1); i < n; i++)
            {
                for (int j = (n * -1); j < n; j++)
                {
                    if (numquadprimes(i, j) > maxprimes)
                    {
                        maxprimes = numquadprimes(i, j);
                        maxi      = i;
                        maxj      = j;
                    }
                }
            }
            return(maxi * maxj);
        }