Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # sum of the even-valued terms in the Fibonacci sequence (starting with 1 and 2) whose values do not exceed four million
- result = 0
- current_number, next_number = 1 , 2
- while current_number < 4000000
- if current_number % 2 == 0
- result += current_number
- end
- current_number, next_number = next_number, current_number + next_number
- end
- puts result
Add Comment
Please, Sign In to add comment