Iteration versus Recursion in the Fibonacci Sequence

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

The Fibonacci sequence is defined by , .


To calculate , say, you can start at the bottom with , then , and so on. This is the iterative method.

Alternatively, you can start at the top with , working down to reach and . This is the recursive method.

The graphs compare the time and space (memory) complexity of the two methods and the trees show which elements are calculated.


Contributed by: Ann Rajan (June 2016)
Special thanks to the University of Illinois NetMath Program and the mathematics department at William Fremd High School.
Open content licensed under CC BY-NC-SA



Snapshot 1: iterative and recursive tree plots for

Snapshot 2: same for

Snapshot 3: same for


[1] T. Cormen et al., Introduction to Algorithms, 3rd ed., Cambridge: The MIT Press, 2009.

[2] E. Lantzman, "Iterative vs. Recursive Approaches." Code Project (blog). (Jun 14, 2016)

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.