Beispiel #1
0
        /// <summary>
        /// Computes the smallest Fibonacci number that is greater than <paramref name="number"/>.
        /// Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
        /// </summary>
        /// <param name="number">The integer we want to compute the closest Fibonacci to it that is bigger than or equal to it. </param>
        /// <returns>The Fibonacci number.</returns>
        public static FibonacciElement GetSmallestFibonacciBiggerThanNumber(int number)
        {
            var fib = new FibonacciElement(0, 1);

            while (fib.FibN < number)
            {
                fib.ShiftForward();
            }
            return(fib);
        }