title: Big O notation estimate
body: <p>Not sure if this is the right place for this kind of question but here it goes. Given the following code, how many basic operations are there, and how many times is each one performed. What is the big O notation for this running time. This is in MATLAB, if it matters.</p>
  
  <pre><code>total = 0;
  
  for i = 1:n
      for j = 1:n
          total = total + j;
      end
  end
  </code></pre>
  
  <p>My thinking is that, for each n, the j = 1:n loop runs once. Within the j = 1:n loop there are n calculations. So for the j = 1:n loop its n^2. This runs n times within the i = 1:n loop, so the total amount of calcultions is n^3, and the big O noation is O(N^3). Is this correct?</p>