Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Numerics;
- namespace Desafio
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch myTimer = Stopwatch.StartNew();
- BigInteger fib1 = BigInteger.One;
- BigInteger fib2 = BigInteger.One;
- BigInteger fib3 = fib1 + fib2;
- int count = 3;
- BigInteger maxNumber = BigInteger.Pow((BigInteger)10, 999);
- while (fib3 < maxNumber)
- {
- fib1 = fib2;
- fib2 = fib3;
- fib3 = fib1 + fib2;
- ++count;
- }
- myTimer.Stop();
- Console.WriteLine("{0}", count);
- Console.WriteLine("{0}", fib3);
- Console.WriteLine("{0} nanosegundos", (double)myTimer.ElapsedTicks / 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement