java 计算 1到10 的 阶层的和(采用递归的方法)
package hibernate; public class t { public static void main(String[] args) { System.out.println(jiecheng(10)); System.out.println(sum(10)); } //算阶乘的和 public static int sum(int i){ if(i>1){ return jiecheng(i)+sum(i-1); } return 1; } //算阶乘 public static int jiecheng(int i){ if(i>1){ return i*jiecheng(i-1); } return 1; } }