Logarithmic run time for calculating prime numbers?
Let's use a different parameter for your input, $m$. The number of instructions that your algorithm executes in the worst case is $O(m)$.

We often measure the running time of algorithms in terms of the length of their input (measured either in bits or in words), often denoted by $n$. The length of your input is $n \approx \log_2 m$, since this is how long it takes to encode the integer $m$ in binary. Therefore your algorithm actually performs an exponential number of instructions $O(2^n)$.

A different issue is the cost of arithmetic operations, such as the modulo operation on line 3. In most models of computation (and in real life), the cost of such an operation depends on the length of the numbers being operated on. Therefore your algorithm runs in time which is worse than $2^n$ by a polynomial factor $n^{O(1)}$ (the exact polynomial factor depends on the algorithm you use to perform the division). Such a running time is usually denoted $\tilde{O}(2^n)$.