Having problem generating Fibonacci sequence

Reply

Join Date: Apr 2007
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Having problem generating Fibonacci sequence

 
0
  #1
Apr 8th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Having problem generating Fibonacci sequence

 
0
  #2
Apr 8th, 2007
Did you write that yourself?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

 
0
  #3
Apr 8th, 2007
I'm sorry...It's not really my program.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Having problem generating Fibonacci sequence

 
0
  #4
Apr 8th, 2007
Wanna know how I knew that. You have a function but with no actual declaration of it. (no Sh*t sherlock!)

Word of advice. Don't try cheating. Try it yourself from the beginning. You'll get a lot more out of it.
Last edited by iamthwee; Apr 8th, 2007 at 11:08 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

 
0
  #5
Apr 8th, 2007
okay, okay, don't get hostile. I'll try it myself and come back. I really do apologize though, for trying to take the easy way out.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 3
Reputation: jimmymerchant is an unknown quantity at this point 
Solved Threads: 0
jimmymerchant jimmymerchant is offline Offline
Newbie Poster

Re: Having problem generating Fibonacci sequence

 
0
  #6
Apr 10th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

 
0
  #7
Apr 27th, 2007
So, how do I get the user to specify the value of N??
If you feed a man a fish, you feed him for a day.
If you teach a man to fish, you feed him for a lifetime.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 29
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Having problem generating Fibonacci sequence

 
0
  #8
Apr 27th, 2007
this way:
  1. int N;
  2. cout<<"Please input n";
  3. cin>>N;
  4. for(j=0;j<N;j++){
  5. temp=temp+temp+1)
  6. }for(i=temp;i<n;i++){
  7. i=i+i+1;
  8. cout>>num;
  9. }
hope u don't mind i used ur code jimmymerchant...

but that's the way it will work with an user input...
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 598
Reputation: anupam_smart is an unknown quantity at this point 
Solved Threads: 4
anupam_smart's Avatar
anupam_smart anupam_smart is offline Offline
Posting Pro

Re: Having problem generating Fibonacci sequence

 
0
  #9
Apr 27th, 2007
Well,
What's gonin' on here guys..
I thought the rule here is to correct an existing code instead of providing a completly new one.
-Must take care of this...
Thanks
# Never say impossible 'cause impossible itself says:

"I M POSSIBLE":) :) :)

#Your I Can is more important than your I.Q.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 29
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Having problem generating Fibonacci sequence

 
0
  #10
Apr 27th, 2007
sorry about that...
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC