Cody

# Problem 12. Fibonacci sequence

Solution 2097980

Submitted on 19 Jan 2020 by kieran Thompson
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))

x = 1 y = 0 f = 1

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

x = 1 y = 0 z = 1 x = 1 y = 1 z = 1 x = 2 y = 1 z = 2 x = 3 y = 2 z = 3 x = 5 y = 3 z = 5 x = 8 y = 5 f = 8

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

x = 1 y = 0 z = 1 x = 1 y = 1 z = 1 x = 2 y = 1 z = 2 x = 3 y = 2 z = 3 x = 5 y = 3 z = 5 x = 8 y = 5 z = 8 x = 13 y = 8 z = 13 x = 21 y = 13 z = 21 x = 34 y = 21 z = 34 x = 55 y = 34 f = 55

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

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

### Community Treasure Hunt

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

Start Hunting!