Differences of the permutations
Practice
3.8 (80 votes)
Basic programming
Basic math
Math basic
Math
Problem
61% Success 9873 Attempts 10 Points 1s Time Limit 256MB Memory 1024 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\)

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...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
1 votes
Tags:
Basic MathC++MathObservation
Points:10
32 votes
Tags:
Basic ProgrammingBasic MathBasics of ImplementationImplementationMath BasicArithmetic operationsMath
Points:10
29 votes
Tags:
Very-Easy