Calculate the nth Fibonacci number.
Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...
Input n = 5
Output f is 5
Input n = 7
Output f is 13
but, loop and conditional statement is forbidden
I hope you will not change the test suite to restrict this ;)
sorry, I forgot to rewrite,so changed.
just kidding. nice problem :)
this is what I want
Very nice! At first the problem felt a bit heavy handed with all those restrictions (no "if", no "round"???) but I see now what you were going for and I like it :)
recursion of anonymous is from the blog of Loren.
the first test (checking 'for' loops, etc.) is not really doing anything...
Thank you , have fixed it.
The thing about these "don't use this don't use that" problems is that there are so many ways around such restrictions.
you are right,it inspires us to create a lot of new idea that is my purpose
The Goldbach Conjecture
Project Euler: Problem 2, Sum of even Fibonacci
Find the biggest empty box
Find nearest prime number less than input number
Multiply by 3
Find the maximum two numbers of every column of a matrix
Return fibonacci sequence do not use loop and condition version 2
Seperate array to small section according to its index position
Generate a vector like 1,2,2,3,3,3,4,4,4,4
Determine if input is a Narcissistic number
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office