[NOIP1998 普及组] 阶乘之和 - 洛谷https://www.luogu.com.cn/problem/P1009
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long sum=0;
for (int i = 1; i <= n; i++) {
sum+=func(i);
}
System.out.print(sum);
}
public static long func(int a) {
if(a==1) {
return 1;
}else {
return a*func(a-1);
}
}
}