Calculate the nth Fibonacci number.
Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...
Examples:
Input n = 5
Output f is 5
Input n = 7
Output f is 13
but, loop and conditional statement is forbidden
Solution Stats
Problem Comments
7 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers851
Suggested Problems
-
Select every other element of a vector
36119 Solvers
-
Find state names that end with the letter A
1197 Solvers
-
795 Solvers
-
16370 Solvers
-
Calculate the average value of the elements in the array
1699 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Solve other problems from the problem set, Basics - Fibonacci, and the answer will reveal itself to you (after a little reflection). I promise.
Could you please tell me how to use recursion without condition?
Nice!
Interesting problem!!
It does require understanding of linear reccurence relations with constant coefficients. Interesting problem overall
Hint Instead using round which is forbidden.Try cast to other data types guys ( ͡° ͜ʖ ͡°)
you can use golden ratio for this problem.