RSS Forums RSS
Please support our C advertiser: Programming Forums
Views: 2178 | Replies: 9
Reply
Join Date: Apr 2007
Location: Mississippi
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Help Having problem generating Fibonacci sequence

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,832
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 324
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Having problem generating Fibonacci sequence

  #2  
Apr 8th, 2007
Did you write that yourself?
... the hat of 'is this a cat in a hat?'
Reply With Quote  
Join Date: Apr 2007
Location: Mississippi
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

  #3  
Apr 8th, 2007
I'm sorry...It's not really my program.
Reply With Quote  
Join Date: Aug 2005
Posts: 4,832
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 324
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Having problem generating Fibonacci sequence

  #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.
... the hat of 'is this a cat in a hat?'
Reply With Quote  
Join Date: Apr 2007
Location: Mississippi
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

  #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  
Join Date: Apr 2007
Posts: 3
Reputation: jimmymerchant is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jimmymerchant jimmymerchant is offline Offline
Newbie Poster

Re: Having problem generating Fibonacci sequence

  #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  
Join Date: Apr 2007
Location: Mississippi
Posts: 48
Reputation: naya22 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
naya22's Avatar
naya22 naya22 is offline Offline
Light Poster

Re: Having problem generating Fibonacci sequence

  #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  
Join Date: Mar 2007
Location: Honduras
Posts: 1,407
Reputation: Nichito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 26
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Having problem generating Fibonacci sequence

  #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  
Join Date: Feb 2006
Location: INDIA
Posts: 446
Reputation: anupam_smart is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
anupam_smart's Avatar
anupam_smart anupam_smart is offline Offline
Posting Pro in Training

Re: Having problem generating Fibonacci sequence

  #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":) :) :)
Reply With Quote  
Join Date: Mar 2007
Location: Honduras
Posts: 1,407
Reputation: Nichito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 26
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Having problem generating Fibonacci sequence

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

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:55 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC