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
-
Find the longest sequence of 1's in a binary sequence.
6683 Solvers
-
2366 Solvers
-
1343 Solvers
-
Who is the smartest MATLAB programmer?
789 Solvers
-
3214 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.