- Related Questions & Answers
- Large Fibonacci Numbers in C#
- Program for Fibonacci numbers in C
- Prime numbers and Fibonacci in C++
- Sum of squares of Fibonacci numbers in C++
- Python Program for Fibonacci numbers
- C++ Program to Find Fibonacci Numbers using Recursion
- C++ Program to Find Fibonacci Numbers using Iteration
- Checking for Fibonacci numbers in JavaScript
- C++ Program to Find Fibonacci Numbers using Matrix Exponentiation
- C++ Program to Find Fibonacci Numbers using Dynamic Programming
- Program for Fibonacci numbers in PL/SQL
- How to print the first ten Fibonacci numbers using C#?
- Alternate bits of two numbers to create a new number in C++
- Fibonacci Series in C#
- Find the GCD of N Fibonacci Numbers with given Indices in C++

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

**Fibonacci Number** is defined as a sequence of numbers that starts with two fixed numbers, generally, **o,1** or **1, 1** and the successive elements of the sequence are the sums of the previous two numbers of the sequence.

For example, Fibonacci series till 8 elements is 0,1,1,2,3,5,8,13,21,34,55,89.

Now, let's generalize this series. Here, the value of the nth term is equal to the sum of (n-1)th and (n-2)th term. So, let's get the mathematical derivation of the formula for the nth term of the Fibonacci series.

T_{n} = T_{n-1} + T_{n-2}

Using this formula to find out the 5th term of the Fibonacci series, we have the 3rd and 4th term given.

T_{5} = T_{4} + T_{4}

T_{5} = 3 + 5 = 8.

**Alternate Fibonacci series** is a Fibonacci series that has values the same as the Fibonacci series but alternate elements are to be printed in the series. For example, the first 4 elements of the alternate Fibonacci series are 0, 1 , 3, 8.

To create a program to print alternate Fibonacci series, we will use the formula and for every element of the series and then print only alternate values of the series.

Step 1 : Initialize the first two values of the series n1 = 0 and n2 = 1. Step 2 : loop from i = 2 to n and follow 3-5 : Step 3 : next element is n3 = n1 +n2 Step 4 : n1 = n2 and n2 = n3 Step 5 : if i%2 == 0 : print n3

#include <iostream> using namespace std; int main(){ int n1=0,n2=1,n3,i,number; cout<<"Enter the number of elements to be present in the series: "; cin>>number; cout<<"Alternate Fibonacci Series is : "; cout<<n1<<" "; for (i=2;i<(number*2);++i){ n3=n1+n2; n1=n2; n2=n3; if(i%2==0) cout<<n3<<" "; } return 0; }

Enter the number of elements to be present in the series: 4 Alternate Fibonacci Series is : 0 1 3 8

Advertisements