As I was playing around with Fermat's little theorem, I came up with another method to check if numbers are prime, if the remainder of the division of $n \over a$ was not $0$ for any integer a between $2$ and $\sqrt n$, then the number should be prime, right?
This seems to work well, it finds all of the same primes as Fermat's little theorem, and has the added advantage of not finding Carmichael numbers.
As the title states, is it correct to say an integer $n$ is prime if $n \bmod a \neq 0$ for all integers $a$ where $2 \leq a \leq\sqrt n$, and why?