- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java Program to Find Even Sum of Fibonacci Series till number N

In this article, we will understand how to find even sum of Fibonacci Series till number N. A Fibonacci series is sequence of numbers formed by the sum of its two previous integers. An even Fibonacci series is all the even numbers of the Fibonacci series.

Fibonacci series generates the subsequent number by adding two previous numbers. Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken 0, 1 or 1, 1 respectively.

Fn = Fn-1 + Fn-2

Hence, a Fibonacci series can look like this −

F8 = 0 1 1 2 3 5 8 13

or, this,

F8 = 1 1 2 3 5 8 13 21

Below is a demonstration of the even sum of Fibonacci series −

**Input**

Suppose our input is −

Value of n is: 10

**Output**

The desired output would be −

Even sum of Fibonacci series is 10945

## Algorithm

Step1- Start Step 2- Declare three integers my_input, i, sum Step 3- Prompt the user to enter two integer value/ Hardcode the integer Step 4- Read the values Step 5- Use a for loop to iterate through the integers from 1 to N and assign the sum of consequent two numbers as the current Fibonacci number. Step 6- Display the result Step 7- Stop

## Example 1

Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .

import java.util.Scanner; import java.io.*; public class FabonacciSum { 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); } }

## Output

Required packages have been imported A reader object has been defined Enter the value of N: 10 Even sum of fibonacci series till number 10 is 10945

## Example 2

Here, the integer has been previously defined, and its value is accessed and displayed on the console.

import java.util.Scanner; import java.io.*; public class FabonacciSum { public static void main(String[] args){ int my_input, j, sum; my_input = 10; System.out.println("The value of N: "); int fabonacci[] = new int[2 * my_input + 1]; fabonacci[0] = 0; fabonacci[1] = 1; sum = 0; for (j = 2; j <= 2 * my_input; j++) { fabonacci[j] = fabonacci[j - 1] + fabonacci[j - 2]; if (j % 2 == 0) sum += fabonacci[j]; } System.out.printf("The even sum of fibonacci series till number %d is %d" , my_input, sum); } }

## Output

The value of N: The even sum of fibonacci series till number 10 is 10945

- Related Articles
- Swift Program to Find Sum of Even Fibonacci Terms Till number N
- Program to find Nth Even Fibonacci Number in C++
- Java program to print Fibonacci series of a given number.
- Java Program to Find sum of even factors of a number
- Java Program for n-th Fibonacci number
- Java Program to Display Fibonacci Series
- 8085 program to find the sum of series of even numbers
- C program to find Fibonacci series for a given number
- Java Program to Find sum of Series with n-th term as n^2 – (n-1)^2
- Java Program for nth multiple of a number in Fibonacci Series
- Java program to print a Fibonacci series
- 8086 program to find sum of Even numbers in a given series
- Average of even numbers till a given even number?
- Java program to print the fibonacci series of a given number using while loop
- Sum of even Fibonacci terms in JavaScript