Showing posts with label Fibonacci Series. Show all posts
Showing posts with label Fibonacci Series. Show all posts

Wednesday, July 6, 2011

Program to find the Fibonacci Series

Fibonacci Series is as follows:-  

0,\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\;


#include<iostream.h>                
#include<conio.h>                   
void main()                         
{
clrscr();                           
int i=0,j=1,k,r,n;                  
cout<<"Enter the Range"<<endl;
cin>>r;                             
cout<<"The Fibonacci Series will be"<<endl;
cout<<i<<endl<<j<<endl;             
for(n=0;n<r;n++)                    
{
k=i+j;                             
i=j;                               
j=k;                               
cout<<k<<endl;                     
}
getch();                          
}