Primality proof for n = 1999:
Take b = 3.
b^(n-1) mod n = 1.
37 is prime.
b^((n-1)/37)-1 mod n = 1308, which is a unit, inverse 81.
3 is prime.
b^((n-1)/3)-1 mod n = 807, which is a unit, inverse 1729.
(3^3 * 37) divides n-1.
(3^3 * 37)^2 > n.
n is prime by Pocklington's theorem.