Description
All Contests ProjectEuler+ Project Euler #2: Even Fibonacci numbers
Project Euler #2: Even Fibonacci numbers
by shashank21j
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
, we have
, we have .
Submissions: 21985
Max Score: 100 Difficulty: Easy
Rate This Challenge:
More
Current Buffer ﴾saved locally, editable﴿ ⚙
1▾
2
3
4
5
6
7▾
8 import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution {
9▾
10
11
12▾
13
14
15
16
17 public static void main(String[] args) { Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int a0 = 0; a0 < t; a0++){
long n = in.nextLong();
}
}
}
Line: 1 Col: 1
Upload Code as File Test against custom input Run Code Submit Code
Join us on IRC at #hackerrank on freenode for hugs or bugs.
Contest Calendar | Interview Prep | Blog | Scoring | Environment | FAQ | About Us | Support | Careers | Terms Of Service | Privacy Policy | Request a Feature
Reviews
There are no reviews yet.