Cody

# Problem 12. Fibonacci sequence

Solution 48622

Submitted on 22 Feb 2012 by Kai
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 g = 0

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

f = 1 g = 0 h = 1 g = 1 f = 1 h = 2 g = 1 f = 2 h = 3 g = 2 f = 3 h = 5 g = 3 f = 5 h = 8 g = 5 f = 8

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

f = 1 g = 0 h = 1 g = 1 f = 1 h = 2 g = 1 f = 2 h = 3 g = 2 f = 3 h = 5 g = 3 f = 5 h = 8 g = 5 f = 8 h = 13 g = 8 f = 13 h = 21 g = 13 f = 21 h = 34 g = 21 f = 34 h = 55 g = 34 f = 55

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

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

### Community Treasure Hunt

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

Start Hunting!