Public feed #602168

Stuff

public text v1 · immutable
Raw Edit
·published 2007-07-03 22:33 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;

namespace euler
{
    class Program
    {
        static void Main(string[] args)
        {
            int nTerm1 = 1;
            int nTerm2 = 2;
            int nTermTemp = 0;
            int nSum = 0;
            Console.WriteLine("Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed one million.");
            Console.WriteLine("Press enter to begin...");
            Console.ReadLine();
            do
            {
                nSum += nTerm1;
                nTermTemp = nTerm1 + nTerm2;
                nTerm1 = nTerm2;
                nTerm2 = nTermTemp;
            }
            while (nTerm1 < 1000000);
            Console.WriteLine("The sum of all the even-valued terms in the Fibonacci sequence which do not exceed one million is " + nSum);
            Console.WriteLine("Press enter to terminate...");
            Console.ReadLine();
        }
    }
}