Cody

# Problem 12. Fibonacci sequence

Solution 536732

Submitted on 28 Nov 2014 by Adam
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% n = 1; f = 1; assert(isequal(fib(n),f))

f = 1

2   Pass
%% n = 6; f = 8; assert(isequal(fib(n),f))

f = 1 t1 = 1 t2 = 1 f = 2 t1 = 1 t2 = 2 f = 3 t1 = 2 t2 = 3 f = 5 t1 = 3 t2 = 5 f = 8 t1 = 5 t2 = 8

3   Pass
%% n = 10; f = 55; assert(isequal(fib(n),f))

f = 1 t1 = 1 t2 = 1 f = 2 t1 = 1 t2 = 2 f = 3 t1 = 2 t2 = 3 f = 5 t1 = 3 t2 = 5 f = 8 t1 = 5 t2 = 8 f = 13 t1 = 8 t2 = 13 f = 21 t1 = 13 t2 = 21 f = 34 t1 = 21 t2 = 34 f = 55 t1 = 34 t2 = 55

4   Pass
%% n = 20; f = 6765; assert(isequal(fib(n),f))

f = 1 t1 = 1 t2 = 1 f = 2 t1 = 1 t2 = 2 f = 3 t1 = 2 t2 = 3 f = 5 t1 = 3 t2 = 5 f = 8 t1 = 5 t2 = 8 f = 13 t1 = 8 t2 = 13 f = 21 t1 = 13 t2 = 21 f = 34 t1 = 21 t2 = 34 f = 55 t1 = 34 t2 = 55 f = 89 t1 = 55 t2 = 89 f = 144 t1 = 89 t2 = 144 f = 233 t1 = 144 t2 = 233 f = 377 t1 = 233 t2 = 377 f = 610 t1 = 377 t2 = 610 f = 987 t1 = 610 t2 = 987 f = 1597 t1 = 987 t2 = 1597 f = 2584 t1 = 1597 t2 = 2584 f = 4181 t1 = 2584 t2 = 4181 f = 6765 t1 = 4181 t2 = 6765

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!