コード例 #1
0
        public long Run()
        {
            var digits = Naturals.Get()
                         .SelectMany(n => n.GetDigits().Reverse())
                         .Take(1000000)
                         .ToList();

            return(digits [0] * digits [9] * digits [99] *
                   digits [999] * digits [9999] * digits [99999] *
                   digits [999999]);
        }
コード例 #2
0
 public static IEnumerable <PythagoreanTriplet> GetAll()
 {
     return
         (from b in Naturals.Get(2)
          from a in Enumerable.Range(1, b - 1)
          let powA = Math.Pow(a, 2)
                     let powB = Math.Pow(b, 2)
                                let powC = powA + powB
                                           let c = Math.Sqrt(powC)
                                                   where c % 1 == 0
                                                   select new PythagoreanTriplet {
         A = a, B = b, C = (int)c
     });
 }