In my book,the $O$-notation is given as:
$$O(g)=\{f:\mathbb N\rightarrow \mathbb R_{\geq 0}:\exists \alpha\in \mathbb R_{>0},\exists n_0 \in \mathbb N : \forall n\geq n_0 f(n)\leq \alpha g(n)\}$$
The algorithm(in pseudocode) for simple primality is given as:
input: $n\in \mathbb N$
output: $result$
main code:
if($n<2$)
result="no" else
for $i\rightarrow 2$ to $\lfloor {\sqrt n}\rfloor$ do
if($i|n$)
result="no"
output result
It says that if $g:n\rightarrow \sqrt n$ where $n\in \mathbb N $, and $f:\mathbb N\rightarrow R_{\geq 0}$ which counts the number of elementary operations of the above given algorithm.Then $f \in O(g)$. I justified this as
No matter what $f(n)\leq \lfloor \sqrt n \rfloor-1 < \lfloor \sqrt n \rfloor \leq g(n)$
and thus, we get the result.But then it states that
One can even say in this case that the algorithm has running time $\Theta(\sqrt n)$, because the number of steps performed by the algorithm is also never less than $\sqrt n$
which is opposite to what I just said.