General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 9/18/2009
Objectives Use Recursion to Solve Problems
Recursive Function Function that refers to itself Example: sum numbers 1 to n function out=sum(n) if n < 1 out = 0; else out = n + sum(n - 1); Termination Condition Simplify Problem, Assemble Results
Factorial product numbers 1 to n
Fibonacci Sequence F n = F n-1 + F n-2 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... each number is the sum of the two previous numbers
Fibonacci Sequence F n = F n-1 + F n-2 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...
Newton’s Method