Published March 12, 2018 by

# Nth Even Fibonacci Number

Nth Even Fibonacci Number

I this post, we'll learn about how to calculate Nth Even Fibonacci Number.

The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones. In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation,

`````` Fn = Fn-1 + Fn-2  with seed values

F0 = 0 and F1 = 1.``````

The even number Fibonacci sequence is : 0, 2, 8, 34, 144, 610, 2584…. We have to find nth number in this sequence.

``The formula of even Fibonacci number =  ((4*evenFib(n-1)) + evenFib(n-2));``

The Below Code shows how to calculate Nth Even Fibonacci Number in Java.

 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9072} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #7e504f} span.s1 {color: #931a68} span.s2 {color: #7e504f} span.s3 {color: #000000} span.s4 {color: #0326cc} span.s5 {text-decoration: underline} span.Apple-tab-span {white-space:pre}  public class NthEvenFibonacciNumber { p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9072} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #7e504f} span.s1 {color: #931a68} span.s2 {color: #7e504f} span.s3 {color: #000000} span.s4 {text-decoration: underline} span.s5 {color: #0326cc} span.Apple-tab-span {white-space:pre} public static void main(String[] args) {     // Here we are passing nth Number int nthNumber = 3; //Calling the getEvenNumber Method And Printing the Nth Even Fibonacci Number number System.out.println(getEvenNumber(nthNumber)); } public static int getEvenNumber(int nthNumber) { if(nthNumber < 1) { return nthNumber; } else if(nthNumber == 1) { return 2; } else { //Formula to calculate Nth Even Fibonacci Number  Fn = 4*(Fn-1) + Fn-2 return ((4 * getEvenNumber(nthNumber - 1)) + getEvenNumber(nthNumber - 2)); } } }

Output :- 34

`If You like my post please like & Follow the blog, And get upcoming interesting topics.`