Series 18

Series 18


1+x^1/1!+x^2/2!+x^3/3!+x^4/4!+..........upto n terms.

import java.util.*;

 class Series20
 {
public static void main(String args[])
throws InputMismatchException{
Scanner scan=new Scanner(System.in);

System.out.println("Enter the limit: ");
int n = scan.nextInt();

System.out.println("Enter a value for x: ");
int x = scan.nextInt();

int i, j, f;
double t, s=0.0;

for(i=0;i < n; i++){

    f = 1;
    for(j=1;j<=i;j++)
        f = f*j;

    t = Math.pow(x,i)/f;

    s = s + t;

}

System.out.println("Sum = "+s);

}//end of main
}//end of class

Have something to say? Log in to comment on this post.

0 comments