Cody

# Problem 232. Project Euler: Problem 2, Sum of even Fibonacci

Solution 1382285

Submitted on 16 Dec 2017 by David Verrelli
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
x =4000000 y_correct = 4613732; assert(isequal(euler002(x),y_correct))

x = 4000000 fib = 1 1 fib = 1 1 2 fib = 1 1 2 3 fib = 1 1 2 3 5 fib = 1 1 2 3 5 8 fib = 1 1 2 3 5 8 13 fib = 1 1 2 3 5 8 13 21 fib = 1 1 2 3 5 8 13 21 34 fib = 1 1 2 3 5 8 13 21 34 55 fib = 1 1 2 3 5 8 13 21 34 55 89 fib = 1 1 2 3 5 8 13 21 34 55 89 144 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 17 610 987 1597 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 18 610 987 1597 2584 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 19 610 987 1597 2584 4181 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 20 610 987 1597 2584 4181 6765 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 21 610 987 1597 2584 4181 6765 10946 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 22 610 987 1597 2584 4181 6765 10946 17711 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 23 610 987 1597 2584 4181 6765 10946 17711 28657 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 24 610 987 1597 2584 4181 6765 10946 17711 28657 46368 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 25 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 26 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 27 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Column 29 514229 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 30 514229 832040 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 31 514229 832040 1346269 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 32 514229 832040 1346269 2178309 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 33 514229 832040 1346269 2178309 3524578 y = 4613732

2   Pass
x =97455000 y_correct = 82790070; assert(isequal(euler002(x),y_correct))

x = 97455000 fib = 1 1 fib = 1 1 2 fib = 1 1 2 3 fib = 1 1 2 3 5 fib = 1 1 2 3 5 8 fib = 1 1 2 3 5 8 13 fib = 1 1 2 3 5 8 13 21 fib = 1 1 2 3 5 8 13 21 34 fib = 1 1 2 3 5 8 13 21 34 55 fib = 1 1 2 3 5 8 13 21 34 55 89 fib = 1 1 2 3 5 8 13 21 34 55 89 144 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 17 610 987 1597 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 18 610 987 1597 2584 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 19 610 987 1597 2584 4181 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 20 610 987 1597 2584 4181 6765 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 21 610 987 1597 2584 4181 6765 10946 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 22 610 987 1597 2584 4181 6765 10946 17711 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 23 610 987 1597 2584 4181 6765 10946 17711 28657 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 24 610 987 1597 2584 4181 6765 10946 17711 28657 46368 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 25 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 26 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 27 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Column 29 514229 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 30 514229 832040 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 31 514229 832040 1346269 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 32 514229 832040 1346269 2178309 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 33 514229 832040 1346269 2178309 3524578 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 34 514229 832040 1346269 2178309 3524578 5702887 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 35 514229 832040 1346269 2178309 3524578 5702887 9227465 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 36 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 37 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 38 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 ...

3   Pass
x =597455000 y_correct = 350704366; assert(isequal(euler002(x),y_correct))

x = 597455000 fib = 1 1 fib = 1 1 2 fib = 1 1 2 3 fib = 1 1 2 3 5 fib = 1 1 2 3 5 8 fib = 1 1 2 3 5 8 13 fib = 1 1 2 3 5 8 13 21 fib = 1 1 2 3 5 8 13 21 34 fib = 1 1 2 3 5 8 13 21 34 55 fib = 1 1 2 3 5 8 13 21 34 55 89 fib = 1 1 2 3 5 8 13 21 34 55 89 144 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 17 610 987 1597 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 18 610 987 1597 2584 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 19 610 987 1597 2584 4181 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 20 610 987 1597 2584 4181 6765 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 21 610 987 1597 2584 4181 6765 10946 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 22 610 987 1597 2584 4181 6765 10946 17711 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 23 610 987 1597 2584 4181 6765 10946 17711 28657 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 24 610 987 1597 2584 4181 6765 10946 17711 28657 46368 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 25 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 26 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 27 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Column 29 514229 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 30 514229 832040 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 31 514229 832040 1346269 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 32 514229 832040 1346269 2178309 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 33 514229 832040 1346269 2178309 3524578 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 34 514229 832040 1346269 2178309 3524578 5702887 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 35 514229 832040 1346269 2178309 3524578 5702887 9227465 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 36 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 37 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Columns 29 through 38 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 ...

4   Pass
x =666576 y_correct = 257114; assert(isequal(euler002(x),y_correct))

x = 666576 fib = 1 1 fib = 1 1 2 fib = 1 1 2 3 fib = 1 1 2 3 5 fib = 1 1 2 3 5 8 fib = 1 1 2 3 5 8 13 fib = 1 1 2 3 5 8 13 21 fib = 1 1 2 3 5 8 13 21 34 fib = 1 1 2 3 5 8 13 21 34 55 fib = 1 1 2 3 5 8 13 21 34 55 89 fib = 1 1 2 3 5 8 13 21 34 55 89 144 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 fib = 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 17 610 987 1597 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 18 610 987 1597 2584 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 19 610 987 1597 2584 4181 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 20 610 987 1597 2584 4181 6765 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 21 610 987 1597 2584 4181 6765 10946 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 22 610 987 1597 2584 4181 6765 10946 17711 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 23 610 987 1597 2584 4181 6765 10946 17711 28657 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 24 610 987 1597 2584 4181 6765 10946 17711 28657 46368 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 25 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 26 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 27 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 fib = Columns 1 through 14 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Columns 15 through 28 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 Column 29 514229 y = 257114