Primality proof for n = 31401709:
Take b = 2.
b^(n-1) mod n = 1.
1993 is prime.
b^((n-1)/1993)-1 mod n = 12526448, which is a unit, inverse 1373451.
101 is prime.
b^((n-1)/101)-1 mod n = 584585, which is a unit, inverse 13470207.
(101 * 1993) divides n-1.
(101 * 1993)^2 > n.
n is prime by Pocklington's theorem.