Thursday, November 24, 2016

Even Fibonacci Numbers

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with  and , the first  terms will be:
By considering the terms in the Fibonacci sequence whose values do not exceed , find the sum of the even-valued terms.
Input Format
First line contains  that denotes the number of test cases. This is followed by  lines, each containing an integer, .
Constraints
Output Format
Print the required answer for each test case.
Sample Input 0
2
10
100
Sample Output 0
10
44
Explanation 0
  • For , we have , sum is .
  • For , we have , sum is .
Note: Write your code in comments section below.

Contact Geek Placement Preparation

Name

Email *

Message *