#K47412. Sum of Even Numbers Up to K
Sum of Even Numbers Up to K
Sum of Even Numbers Up to K
You are given an integer k. Your task is to compute the sum of all even numbers from 1 up to and including k. If k is less than 2, the sum is 0.
The sum of even numbers up to k can be computed using the formula:
[ S = n (n + 1), \quad \text{where} \quad n = \left\lfloor \frac{k}{2} \right\rfloor ]
For example, if k = 10, n = 5 and the answer is 5 \times 6 = 30.
inputFormat
The first line contains an integer m representing the number of test cases. Each of the following m lines contains a single integer k.
Example:
2 4 10
outputFormat
For each test case, output the computed sum on a new line.
Example:
6 30## sample
2
4
10
6
30
</p>