You are on page 1of 10

Fibonacci Numbers

each the sum of its 2 predecessors .Fibonacci • Leonardo Fibonacci • 15th century Italian mathematician • Sequence of numbers 0. 1. 21. 1. 3. 13. 34. … . 2. 5. 8.

Fibonacci numbers .

Fibonacci numbers • the Fibonacci numbers grow almost as fast as the powers of 2 • F30 is over a million • F100 is already 21 digits long! .

Fibonacci numbers • Exponential Algorithm .

Algorithms • Is it correct? • How much time does it take. as a function of n? • And can we do better? .

Algorithm: Correctness • fib1 is Fibonacci’s definition of Fn .

Algorithm: Speed .

Algorithm: Speed • Let T(n) be the computer steps needed to compute fib1(n) • T(n) ≤ 2 for n ≤ 1 • T(n) = T(n-1) + T(n-2) + 3 for n > 1 .