Factorial Recursivo
Factorial Recursivo
Factorial Recursivo
// Factorial
#include <iostream>
double FacR(int X) {
if (X < 2) return 1;
int main()
int n;
for (;;) {
cout << "Ingresar un entero (salir < 0 o > 20): ";
cin >> n;
if (n < 0 || n > 20) break;
cout << "Factorial(" << n << ") = " << FacR(n) << endl;
return 0;
https://evirtual.espe.edu.ec/programas_scorm.cgi?id_curso=19088&id_unidad=210584&id_pkg=47845&wAccion=ver_scos 1/3
23/5/2021 Sistema Virtual de Educación [Contenidos]
# Factorial.py
def FacR(X):
if X < 2:
return 1
return X * FacR(X - 1)
# Funcion principal:
while 1:
Resultados de la corrida
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
Factorial( 3 ) = 6
Ingresar un entero (salir < 0 o > 20): 5
Factorial( 5 ) = 120
>>>
https://evirtual.espe.edu.ec/programas_scorm.cgi?id_curso=19088&id_unidad=210584&id_pkg=47845&wAccion=ver_scos 3/3