Primality proof for n = 166021:
Take b = 2.
b^(n-1) mod n = 1.
2767 is prime. b^((n-1)/2767)-1 mod n = 141431, which is a unit, inverse 162787.
(2767) divides n-1.
(2767)^2 > n.
n is prime by Pocklington's theorem.