输出1!+2!+3!+…+10!的和 1.求1个数的阶乘 2.从1-10每个数的阶乘就和
public class Test{
public static void main(String
[] args
){
int total
= 0;
for(int i
= 1;i
<= 10;i
++) {
total
+= fn(i
);
}
System
.out
.println(total
);
}
public static int fn(int num
) {
int result
= 1;
for(int i
= num
;i
> 0;i
--) {
result
*= i
;
}
return result
;
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-34799.html