Computer Science, asked by ShivHalvawala, 5 months ago

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 BrainlyProgrammer
3

Question:-

  • Write a Java program to find the sum of series:

 \sf S=\dfrac{ {x}^{1}}{(x + 1)! }+  \dfrac{ {x}^{2} }{(x + 2) ! } +  ..... \dfrac{ {x}^{n} }{(x + n)!}

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:-

  1. x=> to accept and store the input from the user
  2. n=> to accept no. of terms from the user
  3. I=> Loop variable
  4. j=> loop variable
  5. s=> to calculate sum of the terms

_______________________

•Output Attached

Attachments:
Similar questions