284 Methods Chapter 6 Fig. 6.13 Recursively generating

284 Methods Chapter 6 Fig. 6.13 Recursively generating Fibonacci numbers (part 3 of 3). The call to fibonacci(line 59) from actionPerformed is not a recursive call, but all subsequent calls to fibonacci performed from the body of fibonacci are recursive. Each time fibonacci is invoked, it immediately tests for the base case n equal to 0 or 1. If this condition is true, fibonacci returns n (fibonacci(0) is 0, and fibonacci(1) is 1). Interestingly, if n is greater than 1, the recursion step generates two recursive calls, each for a slightly simpler problem than the original call to fibonacci. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01

Leave a Reply