Calculate the nth Fibonacci number,return sequence

Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...

in this time,return a function handle

 f  = fib(n)

generate the sequence from the n-th item

if n = 3

first call:

 f() = 2

second call

 f() = 3

third call

 f() = 5

if n = 7

first call:

 f() = 13

second call

 f() = 21

third call

 f() = 34

but, loop and conditional statement is forbidden

Solution Stats

67 Solutions

11 Solvers

Last Solution submitted on Apr 30, 2024

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers11

Suggested Problems

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!