Cody

# Problem 12. Fibonacci sequence

Solution 3372018

Submitted on 25 Oct 2020 by Till Lenczyk
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))

a = 0 b = 1 i = 0 c = 1 b = 1 a = 1 i = 1 f = 1

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

a = 0 b = 1 i = 0 c = 1 b = 1 a = 1 i = 1 c = 1 b = 2 a = 1 i = 2 c = 2 b = 3 a = 2 i = 3 c = 3 b = 5 a = 3 i = 4 c = 5 b = 8 a = 5 i = 5 c = 8 b = 13 a = 8 i = 6 f = 8

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

a = 0 b = 1 i = 0 c = 1 b = 1 a = 1 i = 1 c = 1 b = 2 a = 1 i = 2 c = 2 b = 3 a = 2 i = 3 c = 3 b = 5 a = 3 i = 4 c = 5 b = 8 a = 5 i = 5 c = 8 b = 13 a = 8 i = 6 c = 13 b = 21 a = 13 i = 7 c = 21 b = 34 a = 21 i = 8 c = 34 b = 55 a = 34 i = 9 c = 55 b = 89 a = 55 i = 10 f = 55

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

a = 0 b = 1 i = 0 c = 1 b = 1 a = 1 i = 1 c = 1 b = 2 a = 1 i = 2 c = 2 b = 3 a = 2 i = 3 c = 3 b = 5 a = 3 i = 4 c = 5 b = 8 a = 5 i = 5 c = 8 b = 13 a = 8 i = 6 c = 13 b = 21 a = 13 i = 7 c = 21 b = 34 a = 21 i = 8 c = 34 b = 55 a = 34 i = 9 c = 55 b = 89 a = 55 i = 10 c = 89 b = 144 a = 89 i = 11 c = 144 b = 233 a = 144 i = 12 c = 233 b = 377 a = 233 i = 13 c = 377 b = 610 a = 377 i = 14 c = 610 b = 987 a = 610 i = 15 c = 987 b = 1597 a = 987 i = 16 c = 1597 b = 2584 a = 1597 i = 17 c = 2584 b = 4181 a = 2584 i = 18 c = 4181 b = 6765 a = 4181 i = 19 c = 6765 b = 10946 a = 6765 i = 20 f = 6765

### Community Treasure Hunt

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

Start Hunting!