|
Sum of Series (1+X+X^2+X^3......)
public
class Sum
{
public static void main(String arg[])
{
int n = 10;
int i = 0;
int sum = 0;
int x = 2;
while (i < n)
{
sum += Math.pow(x,i);
i++;
}
System.out.println("Sum of the Series
1+X+X^2+X^3+.... =" + sum);
}
}
Output
:
Sum of the Series 1+X+X^2+X^3+.... = 1023
|