What is the analytical formula for summing up all the blocks in a a pyramid with height $h$ and top layer $(n m)$, with each layer below it $(n+1) (m+1)$ ?
For example: $n = 2, m = 3, h = 10$
sum$ = 2 * 3 + 3 * 4 + 4 * 5 + ... + 11 * 12 = 570$
What is the analytical formula for summing up all the blocks in a a pyramid with height $h$ and top layer $(n m)$, with each layer below it $(n+1) (m+1)$ ?
For example: $n = 2, m = 3, h = 10$
sum$ = 2 * 3 + 3 * 4 + 4 * 5 + ... + 11 * 12 = 570$
Copyright © 2021 JogjaFile Inc.
$$\sum_{i = 0}^{h-1} (n+i)(m+i) = \sum_{i = 0}^{h-1} \left(nm + (n+m)i + i^2\right) = $$ $$hnm + (n+m)\frac{h(h-1)}{2} + \frac{h(h-1)(2h-1)}{6}$$
All that was needed is to know $\sum_{i = 1}^n i = \frac{n(n+1)}{2}$ and $\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}$