2
Needed help to figure out the correct calculation of the order of growth of this code snippet (function of N=2 M)
int sum=0;
for (int i = 0; i < = N; i++)
for(j = 1; j <= N; j++)
for(k = 1; k <= N; k=k+j)
sum++;
The first two FOR cycles have growth order O(N) but in the case of the third FOR cycle I was left with doubts. And then it will be necessary to add up all the growth orders in order to get the final solution.
![somatório de N/k para k em <code>[1,N]</code>](https://i.stack.imgur.com/zEFlZ.png)
In the third loop, you will have
O(floor(N/j))steps for eachj, so it will be the sum withjvarying within[1,N]– Jefferson Quesado