/*
  Factorial Program.
*/

#include <stdio.h>

main()
{
  /*  Factorial n  */

  /*  Declaration Statements  */
  short i, n;
  double fact;
  short FORLIM;

  printf("C46.C -> Factorial Program\n");

  /*  Assignment Statements  */
  printf("Enter the number you want (n!) : ");
  scanf("%hd", &n);
  getchar();
  while (n >= 0) {
    fact = 1.0;
    FORLIM = n;
    for (i = 2; i <= FORLIM; i++)
      fact *= i;

    /*  Print result  */
    printf("Factorial of %3d = %8.0f\n", n, fact);
    printf("\n-------------------------------------\n\n");
    printf("Enter the factorial number you want \n ");
    printf("(enter a negative value to stop the program) : ");
    scanf("%hd", &n);
    getchar();
  }  /*  End of while{} loop  */

  return(0);
}
/*  End of Program C46 */