Cryptography, Python, Math, Mathematics, Diffie Hellman.
Compute the unique integers m and k such that m is odd and x-1 = m(2^k). Let a be a random integer such that 1<a<x. Let b = a^m (mod x) and 1≤r≤(k-1). If b ≡ ±1 (mod x) or b^(2^r)≡-1(mod x), then x is pseudoprime. Otherwise, x is composite. A Brief Example of the Miller-Rabin Primality Test: Here