Primality proof for n = 394049:
Take b = 2.
b^(n-1) mod n = 1.
131 is prime.
b^((n-1)/131)-1 mod n = 283074, which is a unit, inverse 332528.
47 is prime.
b^((n-1)/47)-1 mod n = 340628, which is a unit, inverse 257949.
(47 * 131) divides n-1.
(47 * 131)^2 > n.
n is prime by Pocklington's theorem.