求1+2!+3!+4!+....+20!的和
public class 求阶乘的和 { public static void main(String[] args) { //求1+2!+3!+4!+....+20!的和 int sum=0; for (int i = 1; i <= 20; i++) { sum=sum+getNum(i); } System.out.println(sum); } public static int getNum(int number){ int num=1; for(int i=1;i<=number;i++){ num=num*i; } return num; } }