Esempio n. 1
0
        private int GetAnswerForLargestDivisor(int largestDivisor)
        {
            List <int> allPrimesBelow20 = PrimeGenerator.GetPrimeListWithMaxValue(largestDivisor);
            List <int> primesToLargestPowerStillBelow20 = allPrimesBelow20.Select(
                a =>
                (int)Math.Pow(a,
                              (int)(Math.Log(largestDivisor) / Math.Log(a))
                              )).ToList();
            int smallestAnswer = primesToLargestPowerStillBelow20.Aggregate((a, b) => a * b);

            return(smallestAnswer);
        }
Esempio n. 2
0
        private long GetAnswerWithMaxPrime(int maxPrime)
        {
            List <int> primes = PrimeGenerator.GetPrimeListWithMaxValue(maxPrime);

            return(primes.Sum(a => (long)a));
        }