Cody

# Problem 45223. find nth even fibonacci number

Solution 2057160

Submitted on 13 Dec 2019 by Martin C.
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))

c = 0 one = 1 two = 2 y = 2

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

c = 0 one = 1 two = 2 temp = 2 two = 3 one = 2 temp = 3 two = 5 one = 3 temp = 5 two = 8 one = 5 temp = 8 two = 13 one = 8 temp = 13 two = 21 one = 13 temp = 21 two = 34 one = 21 y = 34

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

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

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

c = 0 one = 1 two = 2 temp = 2 two = 3 one = 2 temp = 3 two = 5 one = 3 temp = 5 two = 8 one = 5 temp = 8 two = 13 one = 8 temp = 13 two = 21 one = 13 temp = 21 two = 34 one = 21 temp = 34 two = 55 one = 34 temp = 55 two = 89 one = 55 temp = 89 two = 144 one = 89 temp = 144 two = 233 one = 144 temp = 233 two = 377 one = 233 temp = 377 two = 610 one = 377 temp = 610 two = 987 one = 610 temp = 987 two = 1597 one = 987 temp = 1597 two = 2584 one = 1597 temp = 2584 two = 4181 one = 2584 temp = 4181 two = 6765 one = 4181 temp = 6765 two = 10946 one = 6765 temp = 10946 two = 17711 one = 10946 temp = 17711 two = 28657 one = 17711 temp = 28657 two = 46368 one = 28657 temp = 46368 two = 75025 one = 46368 temp = 75025 two = 121393 one = 75025 temp = 121393 two = 196418 one = 121393 temp = 196418 two = 317811 one = 196418 temp = 317811 two = 514229 one = 317811 temp = 514229 two = 832040 one = 514229 temp = 832040 two = 1346269 one = 832040 temp = 1346269 two = 2178309 one = 1346269 temp = 2178309 two = 3524578 one = 2178309 temp = 3524578 two = 5702887 one = 3524578 temp = 5702887 two = 9227465 one = 5702887 temp = 9227465 two = 14930352 one = 9227465 temp = 14930352 two = 24157817 one = 14930352 temp = 24157817 two = 39088169 one = 24157817 temp = 39088169 two = 63245986 one = 39088169 temp = 63245986 two = 102334155 one = 63245986 temp = 102334155 two = 165580141 one = 102334155 temp = 165580141 two = 267914296 one = 165580141 temp = 267914296 two = 433494437 one = 267914296 temp = 433494437 two = 701408733 one = 433494437 temp = 701408733 two = 1.1349e+09 one = 701408733 temp = 1.1349e+09 two = 1.8363e+09 one = 1.1349e+09 temp = 1.8363e+09 two = 2.9712e+09 one = 1.8363e+09 temp = 2.9712e+09 two = 4.8075e+09 one = 2.9712e+09 temp = 4.8075e+09 two = 7.7787e+09 one = 4.8075e+09 temp = 7.7787e+09 two = 1.2586e+10 one = 7.7787e+09 temp = 1.2586e+10 two = 2.0365e+10 one = 1.2586e+10 temp = 2.0365e+10 two = 3.2951e+10 one = 2.0365e+10 temp = 3.2951e+10 two = 5.3316e+10 one = 3.2951e+10 temp = 5.3316e+10 two = 8.6268e+10 one = 5.3316e+10 temp = 8.6268e+10 two = 1.3958e+11 one = 8.6268e+10 temp = 1.3958e+11 two = 2.2585e+11 one = 1.3958e+11 temp = 2.2585e+11 two = 3.6544e+11 one = 2.2585e+11 temp = 3.6544e+11 two = 5.9129e+11 one = 3.6544e+11 temp = 5.9129e+11 two = 9.5672e+11 one = 5.9129e+11 temp = 9.5672e+11 two = 1.5480e+12 one = 9.5672e+11 y = 1.5480e+12

### Community Treasure Hunt

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

Start Hunting!