Fermat Little Theorem
Prerequisites
modular arithmetic
模运算,相同的模(Congruent modulo)可以写出一个等式,叫同余式:
同余式完全兼容加减乘,除法的话,当 modulo 是除数的倍数时,需要把 modulo 也除以除数。
Theorem
费马小定理(Fermat Little Theorem),下面是 wikipedia 的解释:
if is a prime number, then for any integer , the number is an integer multiple of . In the notation of modular arithmetic, this is expressed as:
If is not divisible by , Fermat's little theorem is equivalent to the statement that is an integer multiple of , or in symbols:
Improvement
数学归纳法+二项式定理。
当 a = 1 时, 显然成立
设 a = k 时, 成立,
则
则
则 成立
由 1 和 2
得,对任何自然数 , 都成立。
Practice
素数判定的必要非充分条件
快速求模
...
References
Last updated