﻿/* Michael Graham 2015-12-25 */

namespace C_Sharp
{
	public sealed class P0002 : IEulerSolutionInterface
	{
		/// <summary>
		/// By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
		/// </summary>
		/// <returns></returns>
		public string Run ()
		{
			int a = 1, b = 2, sum = 0, temp;
			while ( b < 4000000 )
			{
				if ( b % 2 == 0 )
				{
					sum += b;
				}
				temp = b;
				b = a + b;
				a = temp;
			}

			return sum.ToString();
		}

	}
}
