Differences of the permutations
61% Success9873 Attempts10 Points1s Time Limit256MB Memory1024 KB Max Code

Given an integer N. Consider all the possible permutations \(p[\ ]\) of all integers from \(1\) to \(N\). Calculate the value of \(X\) for each permutation : 

\(X = \sum_{i = 1}^{i = N} N - p[i]\)

Determine the sum of all \(X\) for all possible permutations.

Input format

  • First line: A single integer \(T\) denoting the number of test cases
  • Second line: A single integer N.

Output format

 For each test case, print a single line containing the answer.

Constraints

\(1 \leq T \leq 5\)

\(1 \leq N \leq 10\)

Examples
Input
1
2
Output
2
Explanation

There are 2 possible permutations for N = 2 : p = [1, 2] and p = [2, 1].

For first permutation X = (2 - 1) + (2 - 2) = 1.

For second permutation X = (2 - 2) + (2 - 1) = 1.

So sum of X over 2 possible permutations = 2.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results