Computer Science, asked by Ayushmaanj, 1 year ago

write a program in Java to find the sum of the series S = 1 + x^2 + x^3+.........x^n 100 points answer

Answers

Answered by 9257
4
public static void main(String[] args) { int n = x; int sum = 0;  for (int i = 0; i <= n; i++) { sum = sum + i; } System.out.println(sum);}

Ayushmaanj: not 100
9257: then
Ayushmaanj: 100 points question it was
9257: oh sorry
9257: I thought that was the part it
Ayushmaanj: no problem
Ayushmaanj: and thanks
Answered by AwesomeDhruv
5
import java.until.*;
class series
{
public static void main ()
{
Scanner sc = new Scanner(System.in)
int x, i, S = 1,n;
x = sc.nextInt();
n=a.c..nextInt();
for(i=2;i<= n; i++)
{
S= S+ Math.pow(x,i);
}
System.out.println(S);
}
}
Similar questions