Building Tower
Practice
5 (1 votes)
Basic math
C++
Math
Observation
Problem
53% Success 255 Attempts 10 Points 2s Time Limit 256MB Memory 1024 KB Max Code
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\)
Submissions
Please login to view your submissions
Similar Problems
Points:10
Tags:
Basic MathMathC++
Points:10
10 votes
Tags:
Math BasicAlgorithmsBasic MathMath
3.King Duo
Points:10
1 votes
Tags:
Basic MathAlgorithmsMath
Editorial