Last active
January 22, 2019 13:10
-
-
Save lnrsoft/9747721 to your computer and use it in GitHub Desktop.
Here is my C++ program to generate Fibonacci series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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