Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created March 5, 2017 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adals20/200283eb5810fa7365b5b944c5d6151c to your computer and use it in GitHub Desktop.
Save Adals20/200283eb5810fa7365b5b944c5d6151c to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int fibonacci (int n){
int i, primero = 0, segundo =1, resul =0;
for (i=1; i<n; i++){
resul = primero + segundo;
primero = segundo;
segundo = resul;
}
return resul;
}
int main()
{
int n, resultado;
cout << "Introdusca la posicion para saber que numero le corresponde a la serie de fibonacci" << endl;
cin >> n;
resultado = fibonacci (n);
cout << "El numero es: " << resultado << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment