Description
给定一个整数N,编写程序求1!+2!+……+N!(0
Input
输入一个整数N
Output
输出1!+2!+……+N!
Sample Input
6
Sample Output
873
import java.util.*;
public class Main{
public static void main(String argc[])
{
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
int sum = 0;
int temp = 1;
for(int i = 1;i <= num ;i++)
{
for(int j = 1;j <= i; j++)
{
temp = temp * j;
}
sum += temp;
temp = 1;
}
System.out.println(sum);
}
}