HOWTO计算x的阶乘 [英] Howto compute the factorial of x
本文介绍了HOWTO计算x的阶乘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得一个整数值 X
,由 x所示!
,它的产品数字1到x。
例如: 5! 1x2x3x4x5 = 120。
INT A,B = 1,C = 1,D = 1;
的printf(geheel getal X =);
scanf函数(%d个,&安培; A);
的printf(%D =!,一);
对于(B = 1; B&LT = A; B ++)
{
的printf(%d个X,C);
C ++;
D = D * A;
}
的printf(=%D,D);
解决方案
如何得到一个整数x,由x所示的索姆!是数字1至x的产物
块引用>您的意思是
阶乘
x的?修改
D = D * A;
到D = D * B
内循环how to get the value of an integer
x
, indicated byx!
, it is the product of the numbers 1 to x.Example:
5! 1x2x3x4x5 = 120.
int a , b = 1, c = 1, d = 1; printf("geheel getal x = "); scanf("%d", &a); printf("%d! = ", a); for(b = 1; b <= a; b++) { printf("%d x ", c); c++; d = d*a; } printf(" = %d", d);
解决方案how to get the som of an integer x, indicated by x!, is the product of the numbers 1 to x.
Did you mean
factorial
of x ?Change
d = d*a;
tod = d*b
inside the loop这篇关于HOWTO计算x的阶乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文