参考源代码:
public class Test {
public static void main(String[] args) {
int f = 1;
int sum = 0;
int n = 10;
for(int i=1; i<=n; i++) {
f *= i;
sum += f;
}
System.out.println("1!+2!+...+" + n + "! = " + sum);
运行结果: