求N的阶乘

本题要求编写程序,计算N的阶乘。

输入格式:

输入在一行中给出一个正整数N。

输出格式:

在一行中按照“product = F”的格式输出阶乘的值F,请注意等号的左右各有一个空格。题目保证计算结果不超过双精度范围。

输入样例:

5

输出样例:

在这里给出相应的输出。例如:

product = 120

#include<stdio.h>
main()
{
	int i=1;
	int N;
    double f=1;
	scanf("%d",&N);
	while(i<=N)
	{
		f*=i; 
		i++;
	}
	printf("product = %.0lf",f);
	return 0;
}
发布了67 篇原创文章 · 获赞 44 · 访问量 499

猜你喜欢

转载自blog.csdn.net/Noria107/article/details/104213827