#include
#include
using namespace std;
/*
* This program prints the first few numbers of the
* Fibonacci integer sequence.
*
* @creator gdt
* @created 02017.10.16
* @edu pseudo-code and program written during a csc100 class
* @see https://oeis.org/A000045
* Fibonacci numbers: f(n) = f(n-1) + f(n-2) with f(0) = 0, f(1) = 1
* @caveats program does not protect against overflow
*/
int main(int argc, char* argv[]) {
long prev0 = 0;
long prev1 = 1;
cout << "enter # of Fibonacci numbers: ";
int n;
cin >> n;
if (n < 3) {
n = 32;
cout << "we switched your input to " << n << endl;
}
cout << prev0 << " " << prev1 << " ";
for (n -= 2; n > 0; n--) {
long x = prev0 + prev1;
cout << x << " ";
prev0 = prev1;
prev1 = x;
}
}