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.
function fibonacci(N::Int64)
list = []
i1 = 1
i2 = 2
temp = 0
sum = 0
while i1 <= N
if i2 % 2 == 0
push!(list, i2)
end
temp = i1
i1 = i2
i2 = temp + i2
end
for j in list
sum = sum + j
end
return sum
end