Fibonacci Series

This algorithm finds the fibonacci series. In this algorithm the next number is found by adding up the two numbers before it.

Example of fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...



									/*****Please include following header files*****/
// stdlib.h
/***********************************************/

int* Fibonacci(int count) {
	int* numbers = (int*)malloc(sizeof(int) * count);

	if (count > 1) {
		numbers[0] = 0;
		numbers[1] = 1;
	}

	int i = 2;
	while (i < count) {
		numbers[i] = numbers[i - 1] + numbers[i - 2];
		++i;
	}

	return numbers;
}
								


Example

									int* fibonacciNumbers = Fibonacci(10);
								


Output

									0
1
1
2
3
5
8
13
21
34