Primality proof for n = 311245691:
Take b = 2.
b^(n-1) mod n = 1.
311 is prime.
b^((n-1)/311)-1 mod n = 123550162, which is a unit, inverse 89454809.
29 is prime.
b^((n-1)/29)-1 mod n = 120750128, which is a unit, inverse 134145418.
(29^2 * 311) divides n-1.
(29^2 * 311)^2 > n.
n is prime by Pocklington's theorem.