**Write a JAVA Program of Sum of Series (1+X**

^{2}+X^{3}+X^{4}+…………).
import java.io.*;

import
java.util.*;

public
class a12 {

public static void main(String
args[])throws IOException

{

Scanner br = new Scanner
(System.in);

System.out.println("Enter
the no. of terms");

int p = br.nextInt();

System.out.println("Enter
value of x");

int x = br.nextInt();

double
s=0;

for(int
i=0;i<p;i++)

{

s=s+Math.pow(x,i);

}

System.out.println("sum
is:"+s);

}

}

**OUTPUT:**

Enter the
no. of terms

4

Enter
value of x

2

sum
is:15.0

hey look up this wesite for programmers...www.countcode.com, i worked be myself for 5 months to make it run...you can share and download codes, ask or answer forum questions, and you can count your code lines from your whole life of programming, sincerely Emi

ReplyDelete