Calculate the First 1000-Digit Fibonacci Number

suggest change

Include using System.Numerics and add a reference to System.Numerics to the project.

using System;
using System.Numerics;

namespace Euler_25
{
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger l1 = 1;
            BigInteger l2 = 1;
            BigInteger current = l1 + l2;
            while (current.ToString().Length < 1000)
            {
                l2 = l1;
                l1 = current;
                current = l1 + l2;
            }
            Console.WriteLine(current);
        }
    }
}

This simple algorithm iterates through Fibonacci numbers until it reaches one at least 1000 decimal digits in length, then prints it out. This value is significantly larger than even a ulong could hold.

Theoretically, the only limit on the BigInteger class is the amount of RAM your application can consume.

Note: BigInteger is only available in .NET 4.0 and higher.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


BigInteger:
* Calculate the First 1000-Digit Fibonacci Number

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
25 BigInteger
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script