forked from chennakrishnans/JAVA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheven.java
More file actions
24 lines (24 loc) · 712 Bytes
/
Copy patheven.java
File metadata and controls
24 lines (24 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.Scanner;
import java.io.*;
class even
{
public static void main(String[] args){
int my_input, i, sum;
System.out.println("Required packages have been imported");
Scanner my_scanner = new Scanner(System.in);
System.out.println("A reader object has been defined ");
System.out.println("Enter the value of N: ");
my_input = my_scanner.nextInt();
int fabonacci[] = new int[2 * my_input + 1];
fabonacci[0] = 0;
fabonacci[1] = 1;
sum = 0;
for (i = 2; i <= 2 * my_input; i++) {
fabonacci[i] = fabonacci[i - 1] + fabonacci[i - 2];
if (i % 2 == 0)
sum += fabonacci[i];
}
System.out.printf("Even sum of fibonacci series till number %d is %d" ,
my_input, sum);
}
}