 New update is available. Click here to update.

# Sum or Product

Contributed by
Ankush Gupta
Last Updated: 23 Feb, 2023
Easy 0/40
Avg time to solve 15 mins
Success Rate 80 % Share 1387 upvotes

## 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.
``````
Detailed explanation ( Input/output format, Notes, Images ) ##### Constraints:
``````1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^4
1 <= ‘Q’ <= 2

Time Limit: 1 sec.
``````

#### Sample Input 1 :

``````2
4 1
4 2
``````

#### Sample Output 1 :

``````10
24
``````

#### Explanation of the Sample Input 1:

``````In the first test case, the answer is 10 because all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 + 2 + 3 + 4 is equal to 10.

In the second test case, the answer is 25 because all integers between 1 and 4 are 1, 2, 3, and 4. Hence 1 * 2 * 3 * 4 is equal to 24.
``````

#### Sample Input 2 :

``````2
5 1
5 2
``````

#### Sample Output 2 :

``````15
120
``````  Auto Console