Java program for:
(1+2)+(1+2+3)+(1+2+3+4)………………….for n terms
(1+2)+(1+2+3)+(1+2+3+4)………………….for n terms
int
x =
0
, sum =
0
;
for
(
int
i =
1
; i <= n; i++)
{
for
(
int
j =
1
; j <= (i+
1
); j++)
{
x = x + j;
}
sum = sum + x;
}
System.out.println(
"Result = "
+sum);
No comments:
Post a Comment