Cody

# Problem 45223. find nth even fibonacci number

Solution 2124925

Submitted on 11 Feb 2020 by Chris J
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; y_correct = 2; assert(isequal(even_fib(n),y_correct))

y = 2 f = 2 1 1

2   Pass
n = 3; y_correct = 34; assert(isequal(even_fib(n),y_correct))

y = 2 f = 2 1 1 y = 3 f = 3 2 1 1 y = 5 f = 5 3 2 1 1 y = 8 f = 8 5 3 2 1 1 y = 13 f = 13 8 5 3 2 1 1 y = 21 f = 21 13 8 5 3 2 1 1 y = 34 f = 34 21 13 8 5 3 2 1 1

3   Pass
n = 10; y_correct = 832040; assert(isequal(even_fib(n),y_correct))

y = 2 f = 2 1 1 y = 3 f = 3 2 1 1 y = 5 f = 5 3 2 1 1 y = 8 f = 8 5 3 2 1 1 y = 13 f = 13 8 5 3 2 1 1 y = 21 f = 21 13 8 5 3 2 1 1 y = 34 f = 34 21 13 8 5 3 2 1 1 y = 55 f = 55 34 21 13 8 5 3 2 1 1 y = 89 f = 89 55 34 21 13 8 5 3 2 1 1 y = 144 f = 144 89 55 34 21 13 8 5 3 2 1 1 y = 233 f = 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 377 f = 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 610 f = 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 987 f = 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 1597 f = 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 2584 f = 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 4181 f = 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 6765 f = 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 10946 f = 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 17711 f = 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 28657 f = 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 46368 f = 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 75025 f = 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 121393 f = 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 196418 f = 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 317811 f = 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 514229 f = 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 832040 f = 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1

4   Pass
n = 20; y_correct = 1548008755920; assert(isequal(even_fib(n),y_correct))

y = 2 f = 2 1 1 y = 3 f = 3 2 1 1 y = 5 f = 5 3 2 1 1 y = 8 f = 8 5 3 2 1 1 y = 13 f = 13 8 5 3 2 1 1 y = 21 f = 21 13 8 5 3 2 1 1 y = 34 f = 34 21 13 8 5 3 2 1 1 y = 55 f = 55 34 21 13 8 5 3 2 1 1 y = 89 f = 89 55 34 21 13 8 5 3 2 1 1 y = 144 f = 144 89 55 34 21 13 8 5 3 2 1 1 y = 233 f = 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 377 f = 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 610 f = 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 987 f = 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 1597 f = 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 2584 f = 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 4181 f = 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 6765 f = 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 10946 f = 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 17711 f = 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 28657 f = 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 46368 f = 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 75025 f = 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 121393 f = 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 196418 f = 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 317811 f = 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 514229 f = 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 832040 f = 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 1346269 f = 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 2178309 f = 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 3524578 f = 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 5702887 f = 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 9227465 f = 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 14930352 f = 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 24157817 f = 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 39088169 f = 39088169 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1 y = 63245986 f = 63245986 39088169 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 ...