euler/v/euler002.v

23 lines
341 B
V

import euler
fn even_fibonacci_up_to(n int) []int {
mut result := []int
mut a := 0
mut b := 1
for a + b < n {
if euler.even(a + b) { result << a + b }
temp := b
b = a + b
a = temp
}
return result
}
fn main() {
mut result := 0
for n in even_fibonacci_up_to(4000000) {
result += n
}
println(result)
}