Created
March 4, 2017 18:07
-
-
Save Adals20/e9af0939192e4e60caf1d890fca544ec 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){ | |
if (n==0) | |
return 0; | |
else if (n==1 || n== 2) | |
return 1; | |
else{ | |
return fibonacci (n-1) + fibonacci (n-2); | |
} | |
} | |
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