Problem 2 (written in Ruby)
def fib
i = 1
p = 0
n = 0
while true do
i += 1
n = i + p
p = n
yield p
end
endtotal = 0
fib do |n|
total += n if n % 2 == 0
if 4000000 < total then
total -= n
break
end
endputs total
Problem:
http://odz.sakura.ne.jp/projecteuler/index.php?Problem%202