Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created February 17, 2017 01:30
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/cd186b3f956d85645f67eb4e333a1b2c to your computer and use it in GitHub Desktop.
Save Adals20/cd186b3f956d85645f67eb4e333a1b2c to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int factorial(int x){
if (x == 0)
return 1;
else {
int recurso = factorial(x-1);
int res = x * recurso;
return res;
}
}
int main(){
int x, y;
cout << "Introdusca un numero para calcular su factorial: ";
cin >> x;
y = factorial(x);
cout << "\nEl factorial es: " << y;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment