Cody

# Problem 12. Fibonacci sequence

Solution 885935

Submitted on 4 May 2016 by tr4nshum4n
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 = 1 b = 0 tmp = 0 f = 1

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

a = 1 b = 0 tmp = 0 tmp = 1 b = 1 a = 1 tmp = 2 b = 1 a = 2 tmp = 3 b = 2 a = 3 tmp = 5 b = 3 a = 5 tmp = 8 b = 5 a = 8 f = 8

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

a = 1 b = 0 tmp = 0 tmp = 1 b = 1 a = 1 tmp = 2 b = 1 a = 2 tmp = 3 b = 2 a = 3 tmp = 5 b = 3 a = 5 tmp = 8 b = 5 a = 8 tmp = 13 b = 8 a = 13 tmp = 21 b = 13 a = 21 tmp = 34 b = 21 a = 34 tmp = 55 b = 34 a = 55 f = 55

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

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