Project Euler solutions in various languages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

18 lines
304 B

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() {
println(even_fibonacci_up_to(4000000).reduce(euler.add, 0))
}