...

/

Solution: Fibonacci Sequence

Solution: Fibonacci Sequence

Go over the implementation of generating the Fibonacci sequence.

We'll cover the following...

Solution

Press + to interact
array = [1, 1]
num1 = 1
num2 = 1
10.times do
next_number = num1 + num2
array << next_number
num1 = num2
num2 = next_number
end
puts "The number of rabbit pairs are: #{array.join(', ')}"

Explanation

  • Line 4: We ...