Here is the modified code in Ruby to list all the Fibonacci terms:
main.rb161 chars11 lines
With this modification, the fibo
function will return an array containing all the Fibonacci terms up to the given number n
.
To use the modified code, you can invoke the fibo
function with the desired number as an argument. For example:
main.rb59 chars2 lines
This will print out the Fibonacci terms up to 10
.
Note: The original code you provided had some syntax issues. I fixed those issues and made additional modifications to list all the Fibonacci terms.
tags: ruby, fibonacci
gistlibby LogSnag