Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Last active January 22, 2019 13:10
Show Gist options
  • Save lnrsoft/9747721 to your computer and use it in GitHub Desktop.
Save lnrsoft/9747721 to your computer and use it in GitHub Desktop.
Here is my C++ program to generate Fibonacci series
// This source code written by Roland Ihasz
#include <iostream>
#include <vector>
#include <fstream>
#include <limits.h>
using namespace std;
int main()
{
vector<double> fibo;
fibo.push_back(0);
fibo.push_back(1);
cout << fibo[0] << " ";
for (int i=1; i<INT_MAX; i++)
{
int ii = i-1;
double n = fibo[i] + (fibo[ii]);
fibo.push_back(n);
if (n < INT_MAX)
{
cout << int(n) << " " ;
}
else
return 0;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment