To modify the given program so that the 10th Fibonacci term is 89, you need to change the loop range from 1..n
to 1..(n-2)
. Additionally, you need to update the initial values of a
and b
to 1
and 1
respectively.
Here's the modified program:
main.rb103 chars12 lines
Now, if you call fibo(10)
, it will return 89
, which is the 10th Fibonacci term.
gistlibby LogSnag