evinda said:
For $j=2$, we have these values for $k$: $2,5,8, \dots, 3n^{\frac{2}{3}}$ and for $j=7$, we have these values for $k$: $7,10,13, \dots, 3n^{\frac{2}{3}}$, right? (Thinking)
So, is the inner loop maybe executed $\displaystyle{ \frac{1}{2} \cdot \left ( \lfloor \frac{ 3n^{\frac{2}{3}}-2}{3} \rfloor+1\right ) \cdot (3n^{\frac{2}{3}}-2) }$ times? (Thinking)
Let's see...
The number of times the statement [m]key++;[/m] is executed is something like:
$$
N(2,5,8, \dots, 3n^{\frac{2}{3}})
+N(7,10,13, \dots, 3n^{\frac{2}{3}})
+N(12,15, \dots, 3n^{\frac{2}{3}})
+ \dots
+N(3n^{\frac{2}{3}})
$$
where $N(S)$ is the number of elements in the set $S$.
To be fair, the upper limit is a bit more complex, and slightly lower.
So if we calculate this, we'll get a number that is an upper estimate for the actual number of times.We can write this approximately (erring on the upper side, which corresponds to the "worst" case) as:
$$
\left(\frac{3n^{\frac{2}{3}} - 2}{3}+1\right)
+\left(\frac{3n^{\frac{2}{3}} - 7}{3}+1\right)
+\left(\frac{3n^{\frac{2}{3}} - 12}{3}+1\right)
+ \dots
+1
$$
How many terms are that? (Wondering)