InterviewSolution
Saved Bookmarks
| 1. |
(x+1)+(x+2)+(x+3)+......+(x+n). java program |
|
Answer» hiiExplanation:import java.io.*;import java.lang.Math;CLASS SERIES1{ public static void MAIN(String ar[]){double i,x=0,n=0,sum=0;DataInputStream OBJ= new DataInputStream(System.in);try{ System.out.println(“Enter the value of x:”);x=Integer.parseInt(obj.readLine());System.out.println(“Enter the value of n:”);n=Integer.parseInt(obj.readLine());}catch(IOException e){}for(i=0;i<=n;i++)sum=sum+Math.pow(x,i);System.out.println(“Sum is:”+sum);}} |
|