Está en la página 1de 3

Calcular el factorial de 5

números C#
Erick Cruz / 13 marzo, 2017

2 Votes

1 using System;

2
namespace Ejercicio_Factorial_5_Numeros
3
{
4
class Program
5
{
6
static void Main()
7
{
8
/* Hacer un programa que lea 5 numeros ingresados por el teclado,

9 * calcule el factorial de cada numero y lo muestre en pantalla,

10 * ademas mostrar la suma de los factoriales de los numeros


ingresados */
11
int sumatoria = 0;
12
for (int i = 1; i <= 5; i++)
13
{

14 Console.Write("Ingrese el numero entero {0}: ", i);

15 int numero = int.Parse(Console.ReadLine());


16

17 int factorial = 1;

18 for (int j = 1; j <= numero; j++)

{
19
factorial = factorial * j;
20
}
21

22
sumatoria = sumatoria + factorial;
23
Console.WriteLine("El factorial de {0} es {1}\n\n", numero,
factorial);
24
}
25
Console.WriteLine("La sumatoria de los factoriales es {0}",
26 sumatoria);

27 Console.ReadKey();

28 }

}
29
}
30

31

También podría gustarte