Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <locale.h>
- #include <wchar.h>
- using namespace std;
- //Función recursiva
- int factorial(int n)
- {
- if (n < 2)
- {
- return 1;
- }
- else
- {
- return n*factorial(n - 1);
- }
- }
- int main()
- {
- int num = 0;
- cout << ":: CALCULAR FACTORIAL::\n";
- cout << "Introduzca un número: ";
- cin >> num;
- cout << "\tEl resultado es: " << factorial(num); //Llama a función e imprime el resultado
- system("pause>null");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement