title: Summation for nested loops
body: <p>I hope my question makes sense. I need to come up with the mathematical summation for the following piece of pseudo-code where S1 and S2 are constant operations </p>
  
  <pre><code>          for i ←  1 to n Do
                  for j ← i to n Do
                    S1
                        for k ← 1 to j do
                        S2
  </code></pre>
  
  <p>I have attempted to come up with the equation which is</p>
  
  <pre><code>T(n) = ∑ni=1 ∑nj=i ∑jk=1 1
  </code></pre>
  
  <p>I tried to solve the inner most loop, that is ∑jk=1 1 and my answer is</p>
  
  <pre><code>T(n) = ∑jk=1 1  
  T(n) = [k – 1 + 1] * 1
  T(n) = k
  </code></pre>
  
  <p>which I am not is correct.</p>
  
  <p>I am not sure how to go about completing this summation as I am confused to what the next steps are in calculating it. Any advice is greatly appreciated.</p>
  
  <p>Apologies on the equation syntax I formed above, it did not import properly from Word.</p>
  
  <p>Thank you.</p>