Generating the sequence using numbers. Restricting, indexing on modulo 2, and summing.

library(numbers)
t <- fibonacci(50, sequence = T)
t <- t[t < 4000000]

answer <- sum(t[t %% 2 == 0])