Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created March 4, 2017 18:07
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/e9af0939192e4e60caf1d890fca544ec to your computer and use it in GitHub Desktop.
Save Adals20/e9af0939192e4e60caf1d890fca544ec to your computer and use it in GitHub Desktop.
#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