源程序:
public class Test{
public static void main(String[] args){
System.out.println(fs(20)) ;
}
public static long fun(int i){
long result = 1 ;
int x = 1 ;
while(x <= i){
result = result * x ;
x++ ;
}
return result ;
}
public static long fs(int i){
long sum = 0 ;
int x = 1 ;
while(x <= i){
sum = sum + fun(x) ;
x++ ;
}
return sum ;
}
}
运行结果: