WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Wall Street Quant · Puzzles & Problems · question 25 of 155

You have an infinite supply of coins and you need to make a pyramid with a base of N coins on each side. How many coins do you need?

📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

Let’s first understand the pyramid of coins, which is a tetrahedral structure. For a pyramid with a base of N coins on each side, there will be:

- N rows of coins on the first level

- N-1 rows of coins on the second level

- N-2 rows of coins on the third level

- ...

- 1 row of coins on the Nth level

Now, to calculate the total number of coins required for the pyramid, we need to sum the number of coins in each level. For level k (1 ≤ k ≤ N), there will be k rows and the total number of coins in level k will be the sum of the first k integers, which can be calculated using the formula for the sum of the first n integers:


$$\frac{k(k + 1)}{2}$$

So, the total number of coins required for the pyramid (T) can be calculated as the sum of the coins in all N levels:


$$T(N) = \sum_{k=1}^{N} \frac{k(k + 1)}{2}$$

Let’s simplify this expression by taking out the constant 1/2:


$$T(N) = \frac{1}{2} \sum_{k=1}^{N} k(k + 1)$$

Now, we need to calculate the sum of the series k(k + 1) from k = 1 to k = N. Let’s first expand the expression:


k(k + 1) = k2 + k

Now, we can split the sum into two individual sums:


$$T(N) = \frac{1}{2} \left( \sum_{k=1}^{N} k^2 + \sum_{k=1}^{N} k \right)$$

For these sums, we can use the well-known formulas for the sum of the first n natural numbers and the sum of the squares of the first n natural numbers:


$$\sum_{k=1}^{N} k = \frac{N(N + 1)}{2}$$


$$\sum_{k=1}^{N} k^2 = \frac{N(N + 1)(2N + 1)}{6}$$

Plugging these formulas back in the expression for T(N), we get:


$$T(N) = \frac{1}{2}\left( \frac{N(N + 1)(2N + 1)}{6} + \frac{N(N + 1)}{2} \right)$$

Now we factor out the common terms and simplify the expression:


$$T(N) = \frac{N(N+1)}{12} (2N+1 + 3)$$


$$T(N) = \frac{N(N+1)(2N+4)}{12}$$

Finally, we can simplify this expression further:


$$T(N) = \frac{N(N+1)(N+2)}{6}$$

So, the total number of coins needed to make a pyramid with a base of N coins on each side is:


$$T(N) = \frac{N(N+1)(N+2)}{6}$$

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Wall Street Quant interview — then scores it.
📞 Practice Wall Street Quant — free 15 min
📕 Buy this interview preparation book: 155 Wall Street Quant questions & answers — PDF + EPUB for $5

All 155 Wall Street Quant questions · All topics