Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
IryaDev committed Oct 4, 2022
1 parent 88544ba commit 0719244
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Add Code Here/C++/fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
using namespace std;
const string INFO = "Este programa imprime la sucesion de fibonacci desde \
1 hasta N, \nsiendo este ultimo un numero ingresado por el usuario\n";
int main() {
unsigned long long aux = 1, fib = 0, lim, init;
cout << INFO << endl;
cout << "Ingrese un numero para la sucesion de fibonacci: ";
cin >> lim;
if(lim > 0) {
for(init = 1; init <= lim; init++) {
cout << "[" << fib << "] ";
aux += fib; /* lo mismo que aux = aux + fib; */
fib = aux - fib;
}
} else {
cout << "El numero debe ser mayor a cero!!" << endl;
}
cout << "\n";
return 0;
}

0 comments on commit 0719244

Please sign in to comment.