/**
* @author 冰樱梦
* 时间:2018年下半年
* 题目:数列求和
*
*/
public class Exercise06_13 {
public static void main(String[] args){
System.out.printf("%-10s%-12s","i","m(i)" );
System.out.println("\n————————————————————————————————————————————————");
for(int i=1;i<=20;i++){
System.out.printf("%-10d%-10.4f \n",i,caculateSum(i) );
}
}
public static double caculateSum(double number){
double sum=0;
for(int i=1;i<=number;i++){
sum+=number/(number+1);
}
return sum;
} }
05-08 15:09