Take b = 2.

b^(n-1) mod n = 1.

5171 is prime. b^((n-1)/5171)-1 mod n = 3624545, which is a unit, inverse 4104544.

(5171) divides n-1.

(5171)^2 > n.

n is prime by Pocklington's theorem.