23 lines
409 B
C
23 lines
409 B
C
# include <stdio.h>
|
|
/* Factorial.
|
|
El programa calcula el factorial de un número entero.
|
|
|
|
FAC, I, NUM: variables de tipo entero. */
|
|
void main(void)
|
|
{
|
|
int I, NUM;
|
|
long FAC;
|
|
printf("\nIngrese el numero: ");
|
|
scanf("%i", &NUM);
|
|
if (NUM >= 0)
|
|
{
|
|
FAC = 1;
|
|
|
|
for (I = 1; I <= NUM; I++)
|
|
|
|
FAC *= I;
|
|
printf("\El factorial de %i es: %ld", NUM, FAC);
|
|
}
|
|
else
|
|
printf("\nError en el dato ingresado");
|
|
} |