| | |
Having problem generating Fibonacci sequence
![]() |
I am having problems generating the Fibonacci sequence. I would like to start at 30.
Here is my program:
#include <iostream>
#include <conio>
using namespace std;
int main()
{
int Fibonacci, n;
cout <<"Here is the Fibonacci number sequence until 30 .";
if ( n==1 || n==2 )
return( 1 );
else
cout << Fibonacci(n-1) + Fibonacci(n-2);
getch();
return 0;
}
However, I am getting an error message where the statement is in bold. It is telling me that it is a call of nonfunction.
What am I doing wrong here?
Here is my program:
#include <iostream>
#include <conio>
using namespace std;
int main()
{
int Fibonacci, n;
cout <<"Here is the Fibonacci number sequence until 30 .";
if ( n==1 || n==2 )
return( 1 );
else
cout << Fibonacci(n-1) + Fibonacci(n-2);
getch();
return 0;
}
However, I am getting an error message where the statement is in bold. It is telling me that it is a call of nonfunction.
What am I doing wrong here?
•
•
Join Date: Apr 2007
Posts: 3
Reputation:
Solved Threads: 0
hey its easy to generate a fib series, it just adds the prev 2 nos and then get the third one.
so u cud have for loop to generate it as follows
for(j=0;j<30;j++)
{temp=temp+temp+1)
}
//this generates the fib series till 30
for(i=temp;i<n;i++)
{
i=i+i+1;
printf("%d",& num)
}
// this will generate the remaining fib series from 30 onwards until where u want thats by specifying the value of n!
so u cud have for loop to generate it as follows
for(j=0;j<30;j++)
{temp=temp+temp+1)
}
//this generates the fib series till 30
for(i=temp;i<n;i++)
{
i=i+i+1;
printf("%d",& num)
}
// this will generate the remaining fib series from 30 onwards until where u want thats by specifying the value of n!
this way:
hope u don't mind i used ur code jimmymerchant...
but that's the way it will work with an user input...
c Syntax (Toggle Plain Text)
int N; cout<<"Please input n"; cin>>N; for(j=0;j<N;j++){ temp=temp+temp+1) }for(i=temp;i<n;i++){ i=i+i+1; cout>>num; }
but that's the way it will work with an user input...
-->sometimes i wanna take my toaster in a bath<-- ![]() |
Other Threads in the C Forum
- Previous Thread: removing an element...
- Next Thread: C array I/O
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






