首页 > 编程语言 >阶乘的算法

阶乘的算法

时间:2022-11-02 11:36:04浏览次数:40  
标签:include int scanf 算法 阶乘 main

#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int face=1;
	int i=1;
while(i<=n){
	face*=i;
	i++;
	}
printf("%d!=%d\n",n,face);
}

  n=1*2*3*4……
         n!=?

 

#include <stdio.h>
int main()
{
    int i,n;
    double sum=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        sum=sum*i;
    printf("%d!=%lf",n,sum);
    printf("\n");
    return 0;
}

  

标签:include,int,scanf,算法,阶乘,main
From: https://www.cnblogs.com/xiongwei/p/16850440.html

相关文章