fibonacci series between two numbers
#include<iostream>
int* fib(int);
int main()
{
int count;
std::cout<<"enter number upto which fibonacci series is to be printed"<<std::endl;
std::cin>>count;
int *p=new int[count];
p=fib(count);
int i;
for(i<0;i<=count;i++)
std::cout<<p[i]<&l开发者_JS百科t;std::endl;
return 0;
}
int* fib(int d)
{
int *ar=new int[d];
int p=-1,q=1,r;
int j;
for(j=0;j<=d;j++)
{
r=p+q;
ar[j]=r;
p=q;
q=r;
}
return ar;
delete ar;
}
this program is printing fibonacci series with given count in the series.please share some idea that how can i convert this program to find fibonacci series between two numbers.
If (5*N*N + 4)
or (5*N*N - 4)
for a given N >= 0 is a perfect square then the number is Fibonacci. Employ this method to generate Fibonacci series between two numbers.
精彩评论