MySum类的sum 方法部分的代码如下:
public class MySum { public static long sum() { long sum = 0; long factorial = 1; for (int n = 1; n <= 10; n++) { factorial *= n; sum += factorial; //主要是这两步!! } return sum; } }
MySum类的sum 方法部分的代码如下:
public class MySum { public static long sum() { long sum = 0; long factorial = 1; for (int n = 1; n <= 10; n++) { factorial *= n; sum += factorial; //主要是这两步!! } return sum; } }