c语言__n的阶乘factorial

 
 

#include <stdio.h>
void Factorial(void)
{
 int n = 0, num = 1, i = 1;
start:
 printf("Please input number:");
 scanf_s("%d", &n);
 if (n <= 0)
 { 
  printf("Input number is wrong!\n");
  goto start;
 }
 printf("%d的阶乘公式:1", n);
 do{
  num *= i;
  if (i > 1)
  {
   printf("*%d", i);
  }
  i++;
 } while (i <= n);
 printf("=%d\n", num);
}
int main(void)
{
 while (1)
 {
  Factorial();
 }
 return 0;
}

你可能感兴趣的:(c语言__n的阶乘factorial)