Problem title
Difficulty
Avg time to solve

Maximum Distance
Moderate
15 mins
Convert String
Easy
15 mins
Check If The String Is A Palindrome
Easy
10 mins
Word Wrap
Moderate
20 mins
Maximum sum of non-adjacent elements
Moderate
15 mins
Find similarities between two arrays.
Easy
20 mins
Print Like A Wave
Easy
20 mins
Sum Of Even Numbers Till N
Easy
10 mins
Encode The String
Easy
10 mins
Overlapping Intervals
Easy
24 mins
39

Sum Of Even Numbers Till N

Difficulty: EASY
Contributed By
Avg. time to solve
10 min
Success Rate
90%

Problem Statement

You have been given a number 'N'. Your task is to find the sum of all even numbers from 1 to 'N' (both inclusive).

Example :

Given 'N' : 6
Sum of all even numbers till 'N' will be : 2 + 4 + 6 = 12

Input Format :

The first line of the input contains an integer 'T', denoting the number of test cases.

The first line and the only line of each test case contains an integer 'N'.

Output Format :

For each test case, print a single integer representing the sum of even numbers till 'N'.

Print a single 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^5

Time Limit: 1 sec

Sample Input 1 :

2
6
2

Sample Output 1 :

12
2

Explanation For Sample Input 1 :

For test case 1 :
Sum of all even numbers till 6 will be : 2 + 4 + 6 = 12

For test case 2 :
Sum of all even numbers till 2 will be : 2

Sample Input 2 :

2
4
5

Sample Output 2 :

6
6

Explanation For Sample Input 2 :

For test case 1 :
Sum of all even numbers till 4 will be : 2 + 4 = 6

For test case 2 :
Sum of all even numbers till 5 will be : 2 + 4 = 6
Reset Code
Full screen
copy-code
Console