euler/002.rb
Yann Esposito (Yogsototh) 198b8d0fd3 Initial submit
2011-05-31 17:31:13 +02:00

24 lines
262 B
Ruby

def fib (n)
return 1 if n < 2
x=y=i=1
while i < n
z = x+y
x = y
y = z
i+=1
end
return z
end
j=1
sum=0
x=fib(1)
while x<4000000
x = fib(j)
if x%2 == 0
sum += x
end
j += 1
end
puts sum