Talk:Algo-analysis-TADM2E

From Algorithm Wiki
Revision as of 09:13, 26 May 2020 by Ur3000 (talk | contribs) (Created page with "Hello, I have a solution to the task 2-34 (TADM2E 2.34) but I have no permissions to created/edit anything. Here is the solution: This task refers to this song The_Twelve_Da...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Hello, I have a solution to the task 2-34 (TADM2E 2.34) but I have no permissions to created/edit anything.

Here is the solution:

This task refers to this song The_Twelve_Days_of_Christmas_(song) So we have to calculate the sum like this

1 day - 1 gift 2 day - 1 gift + 2 gifts 3 day - 1 + 2 + 3 n day - 1 + 2 + 3 + ... + n

Formula is

$ \begin{align} &\sum_{i=1}^n \sum_{j=1}^n j\ = \sum_{i=1}^n \frac{n(n+1)}{2} =\\ &= \frac{1}{2}\sum_{i=1}^n n^2 + \frac{1}{2}\sum_{i=1}^n n=\\ &= \frac{n(n+1)(2n+1) + 3n(n+1)}{12} = \frac{(n+1)(n^2+2n)}{6}\ \end{align} $