Why trial division algorithm to find the prime factors of $N$ is $O(\sqrt{N})$, even though you need to check after $\sqrt{N}$?

58 Views Asked by At

I have understood that to check if $N$ is prime, it is enough to check up to $\sqrt{N}$ because if it has divisor up to that point then it's composite number. However, if you want to count all the prime factors of $N$, it is not enough to reach $\sqrt{N}$. For example, 14 has prime factors $2$ and $7$ but $\sqrt{14} < 4$. Am I missing something?