Computer Science, asked by universe9100, 3 days ago

write a java program to find the sum of following series :
x^1-x^2+x^3-x^4+...-x^n, where x=5

Answers

Answered by samarthkrv
2

Answer:

import java.lang.Math;

public class Main

{

public static void main(String[] args) {

 int x = 5;

     for(int i = 1; i <= x; i++){

         System.out.println(Math.pow(x , i) - Math.pow(x , (i+1)));

     }

}

}

Explanation:

Similar questions