source/euler02.rb
def sum_of_even_fibs_up_to(n)
  a, b = 1, 2
  sum = 0
  while a < n + 1
    # puts(a) # little test
    sum += a if a % 2 == 0
    c = a
    a = b
    b += c
  end
  return sum
end
# By considering the terms in the Fibonacci sequence whose values do not exceed
# four million, find the sum of the even-valued terms.
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms.
By considering the terms in the Fibonacci sequence whose values do not exceed four million find the sum of the even - valued terms .
def sum_of_even_fibs_up_to(n)
  a, b = 1, 2
  sum = 0
  while a < n + 1
    sum += a if a % 2 == 0
    c = a
    a = b
    b += c
  end
  return sum
end
def sum_of_even_fibs_up_to ( n ) a , b = 1 , 2 sum = 0 while a < n + 1 sum += a if a % 2 == 0 c = a a = b b += c end return sum end
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms.
By considering the terms in the Fibonacci sequence whose values do not exceed four million find the sum of the even - valued terms .
# puts(a) # little test
n