Iam new to programing, so be gentle!!!!
I have to program the Fibonacci Sequence up tothe first 29 numbers.
The output starts at 1 2 3 5, not 0 1 1 2.
What am I doing wrong to not get the 0 1 output.
Here is the code:
#include <iostream>
using namespace std;
int main()
{
int f[29];
int i;
f[0] = 0;
f[1] = 1;
for (int i = 2; i <=29; i++)
{
f[i] = f[i-1] + f[i-2];
cout << f[i] << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
;
The output I get is:
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
Press any key to continue . . .