Public feed
#602172
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
{
if (nTerm1 % 2 == 0)
{
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();
}
}
}