Alex wants to build a tower of height \(N\) levels. He wants to build the tower as follows: the \(i^{th}\) level of the tower must have \(1 + 2 + ... + (i - 1) + i\) blocks, i.e., the top level of the tower must consist of \(1\) block, the second level must consist of \(1 + 2 = 3\) blocks, the third level must have \(1 + 2 + 3 = 6\) blocks, and so on. The numbering of levels is done from top to bottom.
Find the total number of blocks required to build a tower of height \(N\).
Input Format:
- The first line contains an integer \(T\), which denotes the number of test cases.
- The first line of each test case contains one integer \(N\), denoting the height of the tower.
Output Format:
For each test case, print the total number of blocks required to build a tower of height \(N\).
Constraints:
\(1 <= T <= 10^3\)
\(1 <= N <= 10^5\)
For first test case:
\(N=4\), Alex uses \(1\) block on the \(1^{st}\) level, \(3\) blocks on the \(2^{nd}\) level, \(6\) blocks on the \(3^{rd}\) level, and \(10\) blocks on the \(4^{th}\) level of the tower. So, the total number of blocks required is \(1 + 3 + 6 + 10= 20\). Hence, \(20\) is the answer.
For second test case:
\(N=1\), Alex uses \(1\) block on the \(1^{st}\) level of the tower. So, the total number of blocks required is \(1\). Hence, \(1\) is the answer.
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