challenges/e2/e2.rb

17 lines
221 B
Ruby
Raw Normal View History

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
tmp = current
current += last
last = tmp
sum(last, current, sum)
end
puts sum(0, 1, 0)