I noticed in my fibonacci sequence that I'm getting negative numbers after a certain point:
267914296 433494437 701408733 1134903170
1836311903 -1323752223 512559680 -811192543 -298632863
Does this have to do with the limited range of "int"? or is there something wrong with my code?
Here is the code:
using std::cout;
int main()
{
int n = 50, f1 = 0, f2 = 1, fn = 0, i = 0;
cout << "0 ";
for (i = 0; i < n; i++)
{
fn = f1 + f2;
f2 = f1;
f1 = fn;
cout << fn << " ";
}