In this guide, we’ll walk through how to generate the Fibonacci sequence in the Ruby programming language.
Create a method that generates the Fibonacci sequence.
Build a method that returns an array of the Fibonacci sequence of a pre-defined number of values.
Definition: Characterized by the fact that every number after the first two is the sum of the two preceding ones.
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
Real World Usage
The Fibonacci sequence is a key sequence utilized in a large variety of mathematical equations. Specifically, due to the rapid growth of the Fibonacci sequence, it’s useful when analyzing algorithm performance.
Can be found on the solutions branch on github.