Problem 1997. Compute Fibonacci Number
Solution Stats
Problem Comments
-
1 Comment
This is the same as Problem 12.
Solution Comments
-
1 Comment
This is cool because there's also an explicit equation (Binet) for this!
-
2 Comments
While this is one way of doing it, this solution uses built-in fibonacci function.
There is no built-in fibonacci function. The existing function is a part of the symbolic toolbox and isn't available on Cody.
This code uses recursion on the main function fibonacci.
However, this is also a cheat solution, using regexp to limit the solution size. If you see other solutions like this, please report them using the flag button.
-
1 Comment
This solution returns f(0) = 1, which contradicts the decription of the given problem.
-
3 Comments
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.
-
2 Comments
Problem Recent Solvers415
Suggested Problems
-
21579 Solvers
-
724 Solvers
-
884 Solvers
-
Make a run-length companion vector
614 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
1370 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!