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
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
Answered by
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);
}
}
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
Social Sciences,
8 months ago
Computer Science,
8 months ago
Math,
1 year ago
Science,
1 year ago
Math,
1 year ago
Science,
1 year ago
Science,
1 year ago