Write a java programme to find the sum of series:
S=x^1/(x+1)!+x^2/(x+2)!+x^3/(x+3)!........... x^x/(x+n)!
whoever will solve first and gives me correct answer will me marked brainliest
Answers
Answered by
3
Question:-
- Write a Java program to find the sum of series:
Code:-
package Coder;
import java.util.*;
public class SumSer
{
public static void main (String ar[])
{
Scanner sc=new Scanner (System.in);
System.out.println("Enter a value of x");
int x=sc.nextInt();
System.out.println("Enter no. of terms");
int n=sc.nextInt();
double s=0;
for(int I=1;I<=n;I++)
{
int f=1;
for(int j=1;j<=(x+I);j++)
f*=j;
s+=(Math.pow(x,I))/f;
}
System.out.println("Sum="+s);
}
}
_____________________
Variable Description:-
- x=> to accept and store the input from the user
- n=> to accept no. of terms from the user
- I=> Loop variable
- j=> loop variable
- s=> to calculate sum of the terms
_______________________
•Output Attached
Attachments:
Similar questions