[Template] Miller_Rabin and Pollard_Rho

Miller_Rabin

use

Fast ($ O (slogn) $, s is the number of attempts) to judge whether a number is a prime number

principle

First, there is a $ Fermat's little theorem when ^ {p-1} = 1 (mod \ p) $ established when p is a prime number, it may be randomly selected to be a constant in this equation as the basis for judgment, but not all together this number does not satisfy the equation, the number of co-existence even this formula does not meet all of a

And then with a secondary probe Theorem $ a ^ 2 = 1 (mod p) $, p is an odd prime number was established when $ a = 1 (mod p) $ or $ a = p-1 (mod p) $

Proof: transposition available $ (a-1) (a + 1) = 0 (mod p) $

Guess you like

Origin www.cnblogs.com/Ressed/p/11076543.html