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\)
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
Login to unlock the editorial
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