We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #2: Even Fibonacci numbers

Project Euler #2: Even Fibonacci numbers

  • Problem
  • Submissions
  • Leaderboard
  • Discussions

This problem is a programming version of Problem 2 from projecteuler.net

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 .

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

41743

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature