This solution uses filter from the Signal Processing Toolbox.
Yes, it uses filter, but filter is indeed not a toolbox function, but a built-in function. You can fix the error by changing f=y(n-2) to f = y(n)
... and then change first input of filter to [1,-1] and remove +1 from the end of the line.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
assert(isequal(fibonacci(1),1))
assert(isequal(fibonacci(2),1))
assert(isequal(fibonacci(5),5))
assert(isequal(fibonacci(7),13))
assert(isequal(fibonacci(13),233))
assert(isequal(fibonacci(15),610))
y =
2
|
Project Euler: Problem 2, Sum of even Fibonacci
835 Solvers
246 Solvers
Given a window, how many subsets of a vector sum positive
743 Solvers
2983 Solvers
2314 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!