Write a java program s=1+x+x2+x3+x4+ _____ n term.
PLEASE, WRITE INPUT, OUTPUT AND VARIABLE DESCRIPTION TABLE ALSO.
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 1;
System.out.print("Enter the value for x in the series 1+x+x2+x3+x4+ _____ n term:");
int x = sc.nextInt();
System.out.print("Enter the value for n in the series 1+x+x2+x3+x4+ _____ n term:");
int n = sc.nextInt();
for(int i = 1; i <= n; i++){
sum += (x*i);
}
System.out.println(sum);
}
}
Explanation:
Similar questions