I am trying to count the exact/total number of iterations these nested for-loops are executed:
procedure P (integer n);
for (i: 1 to n)
for (j: 1 to 10)
for (k: n to n+5)
x := x + 1;
I know that the first for loop runs (n-1) times, the second loop runs 10-1 (9) times, thus making the time complexity so far 9(n-1). I know that the the third loop will run n+5-n (5) times, but I am not completely sure because of the n involved. I believe with this calculation added, the total runtime will be 5(9(n-1)) which will translate to O(n). In general, I am wondering if this approach of multiplying the iterations of each loop is a good approach to solving worst case running time and big-Theta estimates. Thanks in advance.