InterviewSolution
Saved Bookmarks
| 1. |
write a program to find the sum of series for the following series 1 + (1*2)+2+(1*2*3)+3+.................9+(1+2+3+.......10) |
Answer» Question:-Write a java program to find the sum of the series. 1+(1*2)+2+(2*3)+.... Program:-import java.util.*; CLASS Sum { public static void MAIN(String args[]) { Scanner sc=new Scanner(System.in); System.out.print("ENTER the NUMBER of TERMS: "); int n=sc.nextInt(), s=0, p=1; for(int i=1;i<=n;i++) { p=i+i*(i+1); s+=p; } System.out.println("Sum of the series is: "+s); } } |
|