关于素数的一些结论
费马测试(Fermat test)
Some of the cryptographic algorithms make use of big prime numbers. However, checking if a big number is prime is not so easy. However, some probabilistic tests exist that offer high confidence at low cost. One of them is the Fermat test.
Let \(a\) be a random number between \(2\) and \(n-1\) (being \(n\) the number whose primality we are testing). Then, \(n\) is probably prime if the following equation holds:
$$a^n \bmod n = a$$
If a number passes the Fermat test several times then it is prime with a high probability.
费马小定理
若 \(p\) 是素数,则对任意正整数 \(x\) 都有
$$x^p \equiv x \pmod{p}$$