Exemplo n.º 1
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            PrimeNumber.CalculateTermsUntilValue(MAX_NUMBER);

            List <Int64> solution = (from p in PrimeNumber.GetListPrimes()
                                     where ((p.ToString().Length == 4) || (p.ToString().Length == 7)) &&
                                     Pandigital.IsPandigital(p)
                                     select p).ToList();

            Console.WriteLine("Solution: {0}", solution.Max());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            const int MAX_NUMBER = 1000000;

            PrimeNumber.CalculateTermsUntilValue(MAX_NUMBER);

            int result = (from p in PrimeNumber.GetListPrimes()
                          where PrimeNumber.IsCircularPrime(p)
                          select p).Count();

            Console.WriteLine("Solution: {0}", result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            PrimeNumber.CalculateTermsUntilValue(10000);

            List <Int64> primes = PrimeNumber.GetListPrimes();

            string solution = (from p1 in primes
                               from p2 in primes
                               from p3 in primes
                               where p1 > 1487 && p2 - p1 == 3330 && p3 - p2 == 3330 &&
                               Permutation.ArePermutations(p1, p2) &&
                               Permutation.ArePermutations(p2, p3)
                               select p1.ToString() + p2.ToString() + p3.ToString()).FirstOrDefault();

            Console.WriteLine("Solution: {0}", solution);
        }
Exemplo n.º 4
0
        static void Main()
        {
            const int MAX_NUMBER = 50000000;

            PrimeNumber.CalculateTermsUntilValue((int)(Math.Sqrt(MAX_NUMBER) + 1));

            HashSet <double> solutions = new HashSet <double>();

            List <Int64> primes = PrimeNumber.GetListPrimes();

            for (int i = 0; i < primes.Count; i++)
            {
                double firstPow = Math.Pow(primes[i], 2);

                if (firstPow <= MAX_NUMBER)
                {
                    for (int j = 0; j < primes.Count; j++)
                    {
                        double secondPow = Math.Pow(primes[j], 3);

                        if (firstPow + secondPow <= MAX_NUMBER)
                        {
                            for (int k = 0; k < primes.Count; k++)
                            {
                                double result = firstPow + secondPow + Math.Pow(primes[k], 4);
                                if (result <= MAX_NUMBER)
                                {
                                    solutions.Add(result);
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Solution: {0}", solutions.Count());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            PrimeNumber.CalculateTermsUntilValue(MAX_VALUE);

            Console.WriteLine("Solution: {0}", PrimeNumber.GetListPrimes().Where(p => (p < MAX_VALUE)).Sum());
        }