challenges/e2/e2.rb

14 lines
185 B
Ruby
Executable File

#!/usr/bin/ruby
def sum(last, current, sum)
if current >= 4000000
return sum
end
if current % 2 == 0
sum += current
end
sum(current,last+ current, sum)
end
puts sum(0, 1, 0)