Problem 3092. Return fibonacci sequence do not use loop and condition
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
Show
4 older comments
Rafael S.T. Vieira
on 12 Jul 2020
Solve other problems from the problem set, Basics - Fibonacci, and the answer will reveal itself to you (after a little reflection). I promise.
泽丰 张
on 12 Sep 2020
Could you please tell me how to use recursion without condition?
Denilson Menezes
on 17 Sep 2020
Nice!
Jiseon Shin
on 1 Nov 2020
Interesting problem!!
Miroslav Popovic
on 4 Feb 2022
It does require understanding of linear reccurence relations with constant coefficients. Interesting problem overall
Tran Tran
on 20 Mar 2022
Hint Instead using round which is forbidden.Try cast to other data types guys ( ͡° ͜ʖ ͡°)
Lam Thai Nguyen
on 28 Dec 2023
you can use golden ratio for this problem.
Solution Comments
Show commentsProblem Recent Solvers548
Suggested Problems
-
Find state names that end with the letter A
1175 Solvers
-
1743 Solvers
-
690 Solvers
-
Who is the smartest MATLAB programmer?
753 Solvers
-
357 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!