Problem title
Difficulty
Avg time to solve

Rearrange Array
Easy
15 mins
Find the Winner
Easy
10 mins
Custom Sort String
Easy
10 mins
Battalions and tanks
Moderate
10 mins
Mirror String
Easy
15 mins
Find the K-th Smallest Element in Array
Easy
10 mins
Median of a row wise sorted matrix
Moderate
30 mins
Minimum Number Of Swaps For Bracket Balancing
Moderate
15 mins
Minimum Rotations
Easy
10 mins
Rotate DLL
Moderate
10 mins
1

First N

Difficulty: EASY
Contributed By

Problem Statement

You are given a positive integer ‘N’. You have to find the sum of first ‘N’ natural numbers.

For Example:
If N = 3.
Sum of the first 3 natural numbers will be 1 + 2 + 3 = 6. Hence, the output will be 6.
Input Format :
The first line of the input contains an integer, 'T’, denoting the number of test cases.

The first line of each test case contains a single positive integer ‘N’.
Output Format :
For each test case, print the sum of first ‘N’ natural numbers.

Print a separate line for each test case.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints :
1 <= T <= 10
1 <= N <= 10^6

Time limit: 1 sec
Sample Input 1 :
2
3
2
Sample output 1 :
6
3
Explanation For Sample Output 1 :
For the first test case,
N = 3.
Sum of the first 3 natural numbers will be 1 + 2 + 3 = 6. Hence, the output will be 6.

For the second test case,
N = 2.
Sum of the first 2 natural numbers will be 1 + 2 = 3. Hence, the output will be 3.
Sample Input 2 :
2
1
4
Sample output 2 :
1
10
Reset Code
Full screen
copy-code
Console