Group Sum Solution Codchef
SOLUTION
” CLICK HERE “
The positive even numbers are sorted in ascending order as 2, 4, 6, 8, 10, 12, 14, 16 ……, and grouped as (2), (4, 6), (8, 10, 12), (14, 16, 18, 20) and so on. Thus, the first group is (2), the second group is (4, 6), the third group is (8, 10, 12), etc. In general, the kth group contains the next k elements of the sequence. Given , find the sum of the elements of the group.
Input:
- First line will contain , number of testcases.
- Next lines have a single integer for each testcase.
Output:
Print the sum of elements in the group in each testcase separated by line break.
Constraints
Sample Input:
2
3
5
Sample Output:
30
130
EXPLANATION:
Case 1: For , the 3rd group has (8, 10, 12). So, . Case 2: For , the 5th group has (22, 24, 26, 28, 30). So, .
Social Plugin