Project Euler Problem #25

in code


My submission was incorrect until I realized that my algorithm starts outputting Fibonacci numbers at the fourth Fibonacci term; it excludes the leading 0,1,1. I therefore set my counter to 3.

using System;
using System.Numerics;

public class TwentyFive
{
	static void Main()
	{
		BigInteger 	a = 1;
		BigInteger 	b = 2;
		BigInteger 	c = 0;
		string 		d = "";
		int 		e = 3;

		do
		{
			c = a + b;
			a = b;
			b = c;
			e++;

			d = Convert.ToString(c);

			if (d.Length == 1000)
				break;

		} while (e < 31337);

		Console.WriteLine("\\n{0}\\n", e);
	}
}


Six Months in the Mountain Kingdom

in me


Your email address will not be published. Required fields are marked *