This is a Coding problem from ProjectEuler.net

Problem 2. Even Fibonacci numbers.

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

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

Solution

The solution to the problem is shown in Figures 1, 2 and 3 on this page. The code is written in PHP. Figures 1 – 3 show the code. Figure 4 shows the output.

Figure 1: Sum of even Fibonacci numbers. Page 1 of code
Figure 2: Sum of even Fibonacci numbers. Page 2 of code
Figure 3: Sum of even Fibonacci numbers. Page 3 of code
Figure 3: Output to Sum of even Fibonacci numbers

Feel free to leave your comments below. I will respond. Thank you.

NB: The full code to the problem can be seen on Github at: https://github.com/ugogineering/sum-of-even-fibonacci-nos-less-than-x/blob/main/sum_of_fibonacci_nos_less_than_x.php