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
-
Return the 3n+1 sequence for n
8487 Solvers
-
Maximum running product for a string of numbers
2253 Solvers
-
Find common elements in matrix rows
2713 Solvers
-
853 Solvers
-
616 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.