-1
I have made the return of some specific elements already, but I am trying to return up to the first. In the code below I returned a certain element, as I create from now until the first, until the fifth and until the decimo?
def element( f )
return f if f <= 1
element( f - 1 ) + element( f - 2 )
end
Explain the need better. Be clearer in what the algorithm should do. I could understand what you did and that you want several numbers, but how do you want this to be provided? Not knowing where you want to go no way serves.
– Maniero
I need to return the elements of Fibonacci until the tenth, I will put an example of the error and you will have an idea ! Note: I already have a spec created. Fibonacci returns the fibonnacci elements up to the tenth Failure/Error: expect(Fibonacci.new.Elements(10)). to eq [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] expected: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] got: 10 (Compared using =) # . /spec/fibonacci_spec.Rb:29:in `block (2 levels) in <top (required)>' Finished in 0.04687 Seconds (files Took 1.27 Seconds to load) 7 examples, 3 failures
– Lucas Cordeiro