题目:求 1+2!+3!+…+20!的和
程序分析:此程序只是把累加变成了累乘。
package lianxi
;
public class 求阶乘
{
public static void main(String
[] args
) {
int total
=0;
int jiecheng
=0;
for(int i
=1;i
<=20;i
++)
{
jiecheng
=i
*i
;
total
=total
+jiecheng
;
}
System
.out
.println("1到20的阶乘为:"+total
);
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-42444.html