コード例 #1
0
        protected override void Solve(out string answer)
        {
            FibonacciSequence fib        = new FibonacciSequence();
            Int64             limitValue = 4000000;
            int   iterator     = 0;
            Int64 currentValue = 0;

            Int64 resultingSum = 0;

            while (currentValue < limitValue)
            {
                currentValue = fib.Get(iterator);
                if (MoreMath.IsEven(currentValue))
                {
                    resultingSum += currentValue;
                }

                iterator++;
            }

            answer = string.Format("Sum of even valued fibonacci numbers under 1 million is: {0}.", resultingSum);
        }