Best Answer:
First of all, how are you going to learn to do your own programming if somebody else is writing the code for you. Secondly, how will you be able to pass the tests that go with the class if you do not understand what to do.

And there are at least three basic ways to calculate the Fibonacci Numbers Sequence:

• An iterative version:

int n = 6; //Fibonacci number desired to be computed.

int fib1 = 0;

int fib2 = 1;

int fib;

for ( int i = 2; i < n; i++ )

{

fib = fib1 + fib2;

fib1 = fib2;

fib2 = fib;

}

• A recursive version:

int fib(int n)

{

if ( n == 0 ) return 0;

if ( n == 1 ) return 1;

return fib(n-1) + fib(n-2);

}

• A dynamic programming version:

vector <int> fib;

fib.push_back(0);

fib.push_back(1);

int n; //N is the number of Fibonacci numbers to compute.

for ( int i = 2; i < n; i++ )

{

fib.push_back( fib[i-1] + fib[i-2] );

}

If you need more coding examples, so that you can look at it to learn what to do on your own, then doing a quick Google search will produce you many results for assisting, such as the following:

#include <iostream>

int main()

{ // define first two fibonacci series numbers.

int fib1 = 0;

int fib2 = 1;

int fib3; // declare variable to store next number of series

int numbers = 2; // declare variable to store how many numbers, default is 2.

int counter = 2; // counter to track how many numbers printed.

std::cout << "How many Fibonacci number you need ? : " ;

std::cin >> numbers;

if (numbers < 3) return 0;

std::cout << fib1 << "\t" << fib2;

do {

counter++;

fib3 = fib1 + fib2;

std::cout << "\t" << fib3;

fib1 = fib2;

fib2 = fib3;

} while (counter <= numbers);

std::cout << std::endl;

system("pause");

return 0;

}

.

Source(s):