m(i)=1/3 + 2/5 +...+ i/(2i+i)

Question:
java program to solve: 

  m(i)=1/3 + 2/5 +...+ i/(2i+i)

Answer:
Use recursion

Code:
import java.util.Scanner;
 
public class Example {
 
   public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      System.out.print("Enter a value: ");
      int n = input.nextInt();
 
      double d = m(n);
      System.out.println("m(5) = " + d );
   }
 
   public static double m(int i) {
      double d = (double)i/(2*i+1);
      if(i <= 1){
        return(d);
      } else {
        return (d + m(i-1));
      }
   }
}

Output:
$ java Example
Enter a value: 5
m(5) = 2.060894660894661