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); }
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); }
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); }
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); }