标题: 经典 [打印本页] 作者: houdongyue 时间: 2016-6-6 21:52 标题: 经典 题目:求1+2!+3!+...+20!的和
public class Twenty_firstFactorialSum {
static long sum = 0;
static long fac = 0;
public static void main(String[] args) {
long sum = 0;
long fac = 1;
for(int i=1; i<=10; i++) {
fac = fac * i;
sum += fac;
}
System.out.println(sum);
}
}