Code:
import java.util.*;class Series
{
public static void main(String args[ ])
{
int limit, s = 0, i ,j , sum = 0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter The Limit: " );
limit=sc.nextInt();
System.out.println("Series:::");
for(i = 1; i <= limit; i++)
{
for(j = 1; j <= (i+1); j++)
{
s = s + j;
}
sum = sum + s;
}
System.out.println("Result = "+sum);
}
}
Output:
Enter The Limit:
10
Series:::
Result = 990
Result = 990
No comments:
Post a Comment