JAVA ICSE BLUEJ program


Ask a Question
Series question

WAP to print the series:-S = 1+(1+2)+(1+2+3)+ --------+(1+2+3--------+n)

//SUPPLY N AS PARAMETER URSELF
class series2
{
void main(int n)
{
int S=0;
for (int c=1;c<=n;c++)
{for (int d=1;d<=c;d++)
{
S=S+d;
}
}
System.out.println(S);
}
}