Either using loop or Recursive function , the result can be achieved .
import java.util.Scanner;
public class Main
{
public static void main (String[]args)
{
try
{
Scanner scanner = new Scanner (System.in);
System.out.print ("Enter X Value : ");
int x = scanner.nextInt ();
int limit = 4;
double y = 0;
for (int i = 1; i <= limit; i++)
y += returnMultiply (x, i);
System.out.println ("Y : " + y);
}
catch (Exception ex)
{
ex.printStackTrace ();
}
}
private static double returnMultiply (int x, int power)
{
double result = 1;
for (int i = 1; i <= power; i++)
result *= (double) (x - 1) / x;
return (double) result / power;
}
}