Enter the number of terms you want in the series as input. Now we use loops and factorials to calculate the sum and get the desired result.
Here is the source code of the Java Program to Find Sum of the Series 1/1! + 2/2! + 3/3! + …N/N!. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Sum_Series
public static void main(String args)
double sum = 0;
System.out.println("1/1! + 2/2! + 3/3! + ..N/N!");
Scanner s = new Scanner(System.in);
System.out.print("Enter the no. of terms in series:");
n = s.nextInt();
Sum_Series obj = new Sum_Series();
for(int i = 1; i <= n; i++)
sum = sum + (double)i / (obj.fact(i));
System.out.println("Sum of series:"+sum);
int fact(int x)
int mul = 1;
while(x > 0)
mul = mul * x;
$ javac Sum_Series.java $ java Sum_Series 1/1! + 2/2! + 3/3! + ..N/N! Enter the no. of terms in series:5 Sum of series:2.708333333333333
Sanfoundry Global Education & Learning Series – 1000 Java Programs.