 New update is available. Click here to update.

# Sum or Product

Last Updated: 3 Dec, 2020
Difficulty: Easy

## PROBLEM STATEMENT

#### For example

``````Given ‘N’ = 4, ‘Q’ = 1.
Then the answer is 10 because the sum of all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 + 2 + 3 + 4 is equal to 10.
``````
##### Input format:
``````The first line of input contains an integer ‘T’ denoting the number of test cases.

Next, ‘T’ lines contain two space-separated integers ‘N’, where ‘N’ is the number given and ‘Q’, denoting the type of query.
``````
##### Output Format :
``````For each test case, You are supposed to return an integer denoting the sum or product of ‘N’ numbers.
``````
##### Note:
``````You are not required to print the expected output; it has already been taken care of. Just implement the function.
``````
##### Constraints:
``````1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^4
1 <= ‘Q’ <= 2

Time Limit: 1 sec.
``````
SIMILAR PROBLEMS

Odd Even

Posted: 31 Oct, 2022
Difficulty: Easy

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022
Difficulty: Moderate

Maximum GCD

Posted: 8 Dec, 2022
Difficulty: Hard

Prime?

Posted: 9 Dec, 2022
Difficulty: Easy

Co-Prime

Posted: 14 Dec, 2022
Difficulty: Hard