The second problem is: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Lets again start with a python script solving this:

from itertools import takewhile, filterfalse
def fib():
lastfib = 1
fib = 0
tmp = 0
while True:
yield fib
tmp = fib
fib = lastfib + fib
lastfib = tmp
print(sum(filterfalse(lambda x: x % 2, takewhile(lambda x: x<4000000, fib()))))

Analytically, I have not gotten far. First thing I notice is that $\textrm{fib}\left(n\right)$ is only even if $n \% 3 = 0$, else it is odd.

Think in binary or follow my proof if you do not believe me:

First step, $\textrm{fib}\left(3 \cdot n\right)$ is always even:

Basis:

Assumption: Holds to $n$, therefore $\textrm{fib}\left(n\right)$ is even

Induction: $n \rightarrow n + 1$

$2 \cdot x, x \in N$ is always even, $\textrm{fib}\left(3 \cdot n\right)$ is even and the sum of even numbers is even as well. Ergo $\textrm{fib}\left(3 \cdot n\right)$ is always even!

But we still have to proof that $\textrm{fib}\left(3 \cdot n\right)$ are the ONLY even numbers!

Lets take a look at $\textrm{fib}\left(3 \cdot n + 2\right)$ which should be always odd:

Basis:

Assumption: Holds to $n$, therefore $\textrm{fib}\left(n + 2\right)$ is odd

Induction: $n \rightarrow n + 1$

A sum of a odd and an even number is always odd hence $\textrm{fib}\left(3 \cdot n+2\right)$ is odd

What is left? $\textrm{fib}\left(3 \cdot n + 1\right)$!

Basis:

Assumption: Holds to $n$, therefore $\textrm{fib}\left(n + 1\right)$ is odd

Induction: $n \rightarrow n + 1$

And again, odd + even = odd!

So the only even numbers in the Fibonacci sequence are the ones with $n \% 3 = 0$!

But that’s it, no idea how to battle this problem further.

Update

Well, after some thinking, I guess I found an analytic solution.

Lets have look which Fibonacci numbers are in the sum of all even Fibonacci numbers: (remember, every third is even)

But these could also be written like this:

This means that and therefore we can also write it as:

We now only need to know what the sum of all Fibonacci numbers to some n is:

Wherefore, the solution is: