import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int sum = 0; 求1! + 2! + ... + n!的和 for (int i = 1; i <= n; i++) { sum += function(i); } System.out.print(sum); } // 求n!的阶乘 public static int function(int n) { if (n < 2) return n; return n * function(n - 1); } }