#C13598. Sum of Even Fibonacci Numbers
Sum of Even Fibonacci Numbers
Sum of Even Fibonacci Numbers
Given a non-negative integer limit, compute the sum of all even Fibonacci numbers that do not exceed limit. The Fibonacci sequence is defined as follows:
\( F_1 = 1, \quad F_2 = 2, \quad F_n = F_{n-1} + F_{n-2} \text{ for } n \geq 3 \)
Your task is to implement a function that reads the input from stdin and writes the result to stdout. For example, when the input is 10, the even Fibonacci numbers are 2 and 8, and their sum is 10.
inputFormat
The input consists of a single non-negative integer limit
provided via standard input.
outputFormat
Output a single integer representing the sum of all even Fibonacci numbers less than or equal to limit
.
10
10