Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
You have been given a series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!, find out the sum of the series till nth term.
Examples:
Input :n = 5 Output : 2.70833 Input :n = 7 Output : 2.71806
// Java program to print the sum of series import java.io.*; import java.lang.*; class GFG { public static double sumOfSeries(double num) { double res = 0, fact = 1; for (int i = 1; i <= num; i++) { /*fact variable store factorial of the i.*/ fact = fact * i; res = res + (i / fact); } return (res); } public static void main(String[] args) { double n = 5; System.out.println("Sum: " + sumOfSeries(n)); } } // Code contributed by Mohit Gupta_OMG <(0_o)> |
chevron_right
filter_none
Output:
Sum: 2.708333333333333
Please refer complete article on Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n! for more details!
Recommended Posts:
- Java Program to Find sum of Series with n-th term as n^2 - (n-1)^2
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
- Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Program to find Sum of the series 1*3 + 3*5 + ....
- Program to find the sum of the series (1/a + 2/a^2 + 3/a^3 + ... + n/a^n)
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n!
- Program to find the sum of a Series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2)
- Program to find Nth term of the series 3, 6, 18, 24, ...
- Program to find Nth term of the series 3 , 5 , 21 , 51 , 95 , ...
- Program to find the Nth term of the series 3, 7, 13, 21, 31.....
- Program to find Nth term in the series 0, 2, 1, 3, 1, 5, 2, 7, 3,…
- Program to find sum of harmonic series

