Example #1
0
        public void Problem25()
        {
            long maxIndex = 1000;
            bool stop     = false;
            Dictionary <long, BigInteger> fibonacci = new Dictionary <long, BigInteger>();

            while (!stop)
            {
                fibonacci = FibonacciHelper.ConstructFibonacciSequenceUptoIndex(maxIndex);
                stop      = fibonacci.Values.Max().ToString().Length >= 1000;
                maxIndex += maxIndex;
            }

            Assert.Equal(4782, fibonacci.First(x => x.Value.ToString().Length == 1000).Key);
        }
Example #2
0
        public void Problem2()
        {
            long maxValue = 4000000;
            long maxIndex = 100;
            bool stop     = false;
            Dictionary <long, BigInteger> fibonacci = new Dictionary <long, BigInteger>();

            while (!stop)
            {
                fibonacci = FibonacciHelper.ConstructFibonacciSequenceUptoIndex(maxIndex);
                stop      = fibonacci.Values.Max() >= maxValue;
                maxIndex += maxIndex;
            }

            Assert.Equal(4613732, fibonacci.Values.Where(x => x < maxValue && x % 2 == 0).Aggregate(BigInteger.Add));
        }