2015-10-19

posted Oct 19, 2015, 4:57 AM by Samuel Konstantinovich   [ updated Oct 19, 2015, 6:59 AM ]
Goal: More basic Recursion

Homework: Go over test at home, use piazza to discuss issues. 


Go Over Exponent
-Basic solution
-Negative exponents

Fibonacci Sequence:
0 1 1 2 3 5 8 13 21 34 55 . . .
We want to write a function (fib n) that returns the nth term of the sequence such that: 0th term is 0, and the 1st term is 1:
(fib 0) -> 0
(fib 1) -> 1
(fib 2) -> 1
(fib 3) -> 2

1. How do you calculate (fib 35) ?
2. How can we express (fib n) recursively using the pattern above?
3. What must we do about base case?


Write the Fibonacci function.
Test it for values you know.
Determine the largest value of n, such that the function returns a value in under 30 seconds. (Start low, work your way up)


Comments