Java的第一个晞月自己打的程序

 
 

1.编写一个程序,求1!+2!+…+10!的值。


package
xxx; public class abc { public static void main(String args[]) { int[] a = {1,2,3,4,5,6,7,8,9,10}; int a_sum = 0; for(int i=0; i < a.length; i++) { a_sum+=jieCheng(a[i]); } System.out.print(a_sum); } public static int jieCheng(int a1) { int re=1; for(int j=1; j<=a1; j++) { re*=j; } return re; } }

猜你喜欢

转载自www.cnblogs.com/sakuraXiYue/p/9693830.html