Series 14

Series 14


x+x^3/3+x^5/5+x^7/7+..........upto n terms.

import java.util.*;

 class Series16
 {
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, p=1;
double b, s=0.0;

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

    b = Math.pow(x,p)/p;
    p = p + 2;
    s = s + b; 
}

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

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

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

0 comments