-
Lenguaje
C
-
Descripción
Mustra el factorial de un número entero positivo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int factorial, i, n;
factorial = 0;
printf ("Ingresa el valor de n: ");
scanf ("%d", &n);
(void) getchar ();
for (i=1; i<=n; i++)
{
printf ("PROCESO %d\n", i);
if(i==1)
factorial=1;
else
factorial=factorial*i;
putchar ('\n');
}
printf ("Valor de factorial: %d\n", factorial);
system ("pause");
return EXIT_SUCCESS;
}
#include <stdlib.h>
int main (void)
{
int factorial, i, n;
factorial = 0;
printf ("Ingresa el valor de n: ");
scanf ("%d", &n);
(void) getchar ();
for (i=1; i<=n; i++)
{
printf ("PROCESO %d\n", i);
if(i==1)
factorial=1;
else
factorial=factorial*i;
putchar ('\n');
}
printf ("Valor de factorial: %d\n", factorial);
system ("pause");
return EXIT_SUCCESS;
}