 <p>Time complexity for that algorithm is <code>O(NlogN)</code>.</p> <p>The <code>for</code> loop is executed <code>N</code> times (from <code>0</code> to <code>N</code>).</p> <p>The <code>while</code> loop is executed <code>logN</code> times since your are dividing the number to half each time.</p> <p>Since your are executing the <code>while</code> inside the <code>for</code>, your are executing a <code>logN</code> operation <code>N</code> times, from there it is the <code>O(NlogN)</code>.</p> <p>All remaining operations (assign, multiplication, division, sum) you can assume that takes <code>O(1)</code></p>