Created
March 5, 2017 05:56
-
-
Save Adals20/200283eb5810fa7365b5b944c5d6151c to your computer and use it in GitHub Desktop.
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
#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