Time complexity of printing prime numbers within a range?
Both &quot;the time complexity is $O( end \cdot \sqrt{end} )$&quot; and  &quot;the time complexity is $O( (start-end) \cdot \sqrt{end} )$&quot; are correct statements (assuming that arithmetic operations on the involved integers can be performed in constant time).
The second upper bound is tighter in some cases. For example, setting $start=end-10$ the first upper remains unchanged while the second one simplifies to $O(\sqrt{end})$.
Also notice that &quot;In  notation  represents the problem size, which is the range between start and end in your case.&quot; is false.
The size of (any reasonable encoding of) the instance is $O(\log end)$.