#K65357. Sum of Natural Numbers
Sum of Natural Numbers
Sum of Natural Numbers
You are given several test cases. For each test case, you will be given a single integer n
, and your task is to compute the sum of the first n natural numbers. This sum can be computed using the formula:
$$ S = \frac{n(n+1)}{2} $$
Output the result for each test case on a new line.
inputFormat
The input is read from stdin
and is structured as follows:
- The first line contains an integer
T
, the number of test cases. - Each of the following
T
lines contains a single integern
.
outputFormat
For each test case, print the sum of the first n
natural numbers to stdout
on a new line.
3
1
2
3
1
3
6
</p>