package chapter6;

import java.util.*;

public class SumSeries6_13 {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    
    System.out.println("Enter an integer for length of series: ");
    int seriesLength = input.nextInt();
    
    System.out.println("i          m(i)\n______________");
    for (int i = 1; i <= seriesLength; i++ ) {
      System.out.printf("%-3d%14.4f\n", i, sumSeries(i));
    }
  }
  
  public static double sumSeries(int n) {
    double sum = 0;
    for (double i = 1; i <= n; i++) {
        sum += i / (i + 1);
    }
    return sum;
  }
} 