Created
February 17, 2017 01:30
-
-
Save Adals20/cd186b3f956d85645f67eb4e333a1b2c 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 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