= 34
N = Vector{Int}(undef, N)
x 1] = 0
x[2] = 1
x[for n = 2:N-1
+1] = x[n] + x[n-1]
x[nend
println(sum(filter(iseven, x)))
4613732
Problem 2
Kevin Silberberg
April 14, 2025
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:
\[\begin{align} 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, \cdots \end{align}\]
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
The fibonacci sequence can be thought of as a discrete dynamical system or a recurrance relation defined as follows,
\[\begin{align} x_{n+1} = x_{n} + x_{n-1} \end{align}\]
where \(x_{0} = 0\) and \(x_{1} = 1\) and \(n = 1, 2, 3, \cdots, N\).
When \(N = 35\) the value \(x_{N}\) exceeds four million, thus we will solve for the fibonacci numbers up to the value \(N = 34\) and then use a julia filter
function along with the iseven
conditional function to sum only the even values.