//小淇在敲代码
package p3;
import java.util.Scanner;
public class 利用递归求阶乘 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner inp=new Scanner(System.in);
System.out.print("请输入一个正整数n=");
int n=inp.nextInt();
System.out.println("1!+2!+3!+...+n!="+getSum(n));
}
public static long getSum(int m)
{
long sum;
if(m==1)
sum=factor(1);
else
sum=getSum(m-1)+factor(m);
return sum;
}
public static long factor(int n)
{
if(n==1)
return 1;
else
return n*factor(n-1);
}
}