Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,230 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,098 people online right now. Registration is fast and FREE... Join Now!




fibunacci series without arrays

 
Reply to this topicStart new topic

fibunacci series without arrays, progrram without array

aamua
post 12 Mar, 2008 - 06:23 AM
Post #1


New D.I.C Head

*
Joined: 12 Mar, 2008
Posts: 1

wub.gif
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 12 Mar, 2008 - 06:34 AM
Post #2


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


To work the Fibonacci sequence you only need to keep track of the last two elements. So a simple swap/rotate is all you really need. Something like:

temp = f1;
f1= f1 + f2; // current fibonacci number...
f2 = temp;

There are a TON of formulas for calculations within the fibonacci sequence. So if the traditional method is too slow there are lots of others.

You can also use a nice recursive algorithm -- you should be able to search for this as it is a "prototypical" example of recursion and has been done by just about every computer science student on the planet earth and probably other planets as well.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM

Go to the top of the page

Stepler
post 12 Mar, 2008 - 07:36 AM
Post #3


New D.I.C Head

*
Joined: 4 Mar, 2008
Posts: 27



Thanked 2 times
My Contributions


Here your task.

~Mod Edit: Solution removed~ Please let the user show some effort before offering a solution.
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 12 Mar, 2008 - 03:58 PM
Post #4


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


nice, but please don't provide solutions until the user has show some effort to solve the problem on their own. As your solution points out, the program is very simple and anyone who gives it a try can solve it... or find it with google... all it takes is a little effort.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 09:28PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month