Esempio n. 1
0
        public long Solve()
        {
            var sum = 0L;
            var primes = new Prime(Limit / 2).PrimeList;

            var count = primes.Count();

            for (var i = 0; i < count; i++)
            {
                if (primes[i] * primes[i] > Limit)
                {
                    break;
                }

                for (var j = i + 1; j < count; j++)
                {
                    if (primes[i] * primes[j] > Limit)
                    {
                        continue;
                    }

                    sum += this.MaxSumLimit(primes[i], primes[j], Limit);
                }
            }

            return sum;
        }
Esempio n. 2
0
 // chvilku to trva vypocet
 public long Solve()
 {
     var sum = 0L;
     var primes = new Prime(Limit);
     for (var number = 2; number <= Limit; number++)
     {
         sum += primes.Totient(number);
     }
     return sum;
 }
Esempio n. 3
0
        public long Solve()
        {
            var primes = new Prime(Max);
            var radValues = new Dictionary<long, long> { { 1, 1 } };

            for (var n = 2; n <= Max; n++)
            {
                var primeFactorization = primes.GetDecomposition(n);
                var product = primeFactorization.Aggregate(1L, (current, p) => current * p.Key);
                radValues.Add(n, product);
            }

            var count = 0;
            foreach (var radValue in radValues.OrderBy(t => t.Value).ThenBy(t => t.Key))
            {
                count++;
                if (count == 10000)
                    return radValue.Key;
            }

            return 0;
        }
Esempio n. 4
0
        public long Solve()
        {
            var resultsCount = 0;
            var primes = new Prime((Limit / 2) + 1).PrimeList;

            foreach (var prime1 in primes)
            {
                foreach (var prime2 in primes)
                {
                    var composite = prime1 * prime2;
                    if (composite < Limit)
                    {
                        resultsCount++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            foreach (var prime in primes)
            {
                var composite = prime * prime;
                if (composite < Limit)
                {
                    resultsCount++;
                }
                else
                {
                    break;
                }
            }

            return resultsCount / 2;
        }