Learn more about the Fibonacci sequence (1:1) and how it handles two conditions in an example base case, counting down to the last two numbers.
- [Instructor] Hopefully, you're familiar…with the Fibonacci series.…This is a real good example of recursion.…The Fibonacci series starts with the number: one, one.…It's a series, and basically you take…the two numbers preceding the current number…to get the next number.…So one plus one would give me two.…Two plus the preceding number, one, would give me three.…Three plus the preceding two would give me five.…Five plus three would give me eight, et cetera.…Fibonacci is really interesting,…because it actually occurs a lot in nature.…
For example, the pattern of a sunflower…or the pattern of a conch shell.…All right.…Fibonacci is also an example where the base case actually…is going to be looking for two conditions.…When I get down,…I want to print so many numbers of the series.…That's the goal of this program.…But when I get down to printing…the first and second number of the series,…I know they're just going to be one and one.…So my base case is going to be,…if the value of the series that I'm trying to print…is equal to one or two,…
Programmers involved in mathematical computations, such as mathematical induction, are probably the biggest users of recursion. You probably know some of the most common recursive problems; finding the factorial of a number and the Fibonacci series are both examples of recursive processes. In this course, staff instructor and Java expert Peggy Fisher explores programming solutions involving both of these problems. She reviews the concept of recursion, discusses approaches to solving problems using recursion, and examines some recursive examples.
- Defining recursion
- Reviewing recursive examples
- Converting decimal to binary
- Printing a LinkedList
- Writing a power function