2011-04-03 06:53:00 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
def sum(last, current, sum)
|
|
|
|
if current >= 4000000
|
|
|
|
return sum
|
|
|
|
end
|
|
|
|
if current % 2 == 0
|
|
|
|
sum += current
|
|
|
|
end
|
2011-04-04 16:24:53 +00:00
|
|
|
sum(current,last+ current, sum)
|
2011-04-03 06:53:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
puts sum(0, 1, 0)
|