Primality proof for n = 495959:
Take b = 2.
b^(n-1) mod n = 1.
503 is prime.
b^((n-1)/503)-1 mod n = 199417, which is a unit, inverse 95122.
29 is prime.
b^((n-1)/29)-1 mod n = 667, which is a unit, inverse 473652.
(29 * 503) divides n-1.
(29 * 503)^2 > n.
n is prime by Pocklington's theorem.