wap in java to find sum of the series 1+(1+2)+(1+2+3)+(1+2+3+-----+n) and also mention variable description.
Answers
Answered by
0
Answer:
import java.util.*;
public class Java{
public static void main(String []args){
Scanner in=new Scanner(System.ib);
int n =in.nextInt();
int s=0;
for(int i=1;i<=n;i++){
s=s+(i*(n-i+1));
}
System.out.println(s);
}
}
Explanation:
Similar questions