Exemplo n.º 1
0
 public static void Run()
 {
     var fib = new FibonacciGenerator();
     BigInteger sum = 0;
     BigInteger lastFib;
     while ((lastFib = fib.Next()) < 4000000)
     {
         if (lastFib%2 == 0)
             sum += lastFib;
     }
     Console.WriteLine(sum);
 }
Exemplo n.º 2
0
        public static void Run()
        {
            var        fib = new FibonacciGenerator();
            BigInteger sum = 0;
            BigInteger lastFib;

            while ((lastFib = fib.Next()) < 4000000)
            {
                if (lastFib % 2 == 0)
                {
                    sum += lastFib;
                }
            }
            Console.WriteLine(sum);
        }
Exemplo n.º 3
0
        public static void Run()
        {
            var targetDigitCount = 1000;

             var generator = new FibonacciGenerator();
             int digitCount;
             var fibCount = 0;
             do
             {
                 var nextInSequence = generator.Next();
                 fibCount++;
                 digitCount =nextInSequence.ToString().Length;
             } while (digitCount < targetDigitCount);

             Console.WriteLine("The {0}th fibonacci term is the first one with {1} digits",
                 fibCount, targetDigitCount);
        }
Exemplo n.º 4
0
        public static void Run()
        {
            var targetDigitCount = 1000;

            var generator = new FibonacciGenerator();
            int digitCount;
            var fibCount = 0;

            do
            {
                var nextInSequence = generator.Next();
                fibCount++;
                digitCount = nextInSequence.ToString().Length;
            } while (digitCount < targetDigitCount);

            Console.WriteLine("The {0}th fibonacci term is the first one with {1} digits",
                              fibCount, targetDigitCount);
        }