测试程序

来源:互联网 发布:网络直播的看法评论 编辑:程序博客网 时间:2024/05/17 07:02
源程序:
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 ;
}
}
运行结果:
测试程序

0 0
原创粉丝点击