
Originally Posted by
Th3T3chGuy
import java.util.Scanner; public class Text1{ public static void main(String [] args){ Scanner input = new Scanner(System.in); int answer = 1; int number = 0; int x; System.out.print("Enter number: "); number = input.nextInt(); System.out.print("Enter value of x: "); x = input.nextInt(); for (int i=1; i<=number;i++) if (answer += i * x){ System.out.println(i); } } } The task is to write a program to find the sum of a number of terms of the infinite series 1 + x + x2 + x3 + x4 + .... xn where the number of terms n to be evaluated and the value of x are input before the summation begins.
Note: x0 = 1 AND x1 = x are known mathematical values
What do you guys think?
And...... ?
What is the problem in code?
What are the errors?
What is the problem, you are facing?
Be precise and get precise answers.