The Lucas Lehmer Riesel Test can test if a number of a certain form is prime or composite. Let $N=6143$. I already know this number is prime so the should find $N \vert u_{n-2}$ but the test ends with $u_{n-2}=531$.
$N$ can be written as $k\cdot2^n-1=3 \cdot 2^{11} -1$ so $u_o=5778$ according to the Wikipedia article since $k=3$.
I have written a simple Python program.
p=11
k=3
M=(2**11)-1
u=5778
for i in range(p-2):
u = ((u*u)-2) % M
print("u_{} = {}".format(i+1, u))
The output is
u_1 = 759
u_2 = 872
u_3 = 945
u_4 = 531
u_5 = 1520
u_6 = 1382
u_7 = 71
u_8 = 945
What is going wrong?
u_9 = 531
You’re not actually using $k$ (nor $p$); you wrote
M=(2**11)-1instead ofM=k*(2**p)-1.