Beispiel #1
0
        public static IEnumerable <long> Get(long n)
        {
            foreach (var p in Primes.Get())
            {
                if (n % p != 0)
                {
                    continue;
                }

                yield return(p);

                n = n / p;
                if (n == 1)
                {
                    break;
                }
            }
        }
Beispiel #2
0
        public long Run()
        {
            var cache = new List <int> ();
            var found = new List <int> ();

            foreach (var longPrime in Primes.Get())
            {
                var prime = (int)longPrime;
                cache.Add(prime);
                if (prime < 10)
                {
                    continue;
                }

                var digits = prime.GetDigits().Reverse();
                if (digits.Contains(0))
                {
                    continue;
                }
                if (!CheckPrimeDigits(cache, digits, true))
                {
                    continue;
                }
                if (!CheckPrimeDigits(cache, digits, false))
                {
                    continue;
                }

                found.Add(prime);
                if (found.Count == 11)
                {
                    return(found.Sum());
                }
            }

            throw new Exception("Should not reach here");
        }
Beispiel #3
0
 public long Run()
 {
     return(Primes.Get()
            .Skip(10000)
            .First());
 }