费马小定理
如果 \(p\) 是质数,则对任意整数 \(a\) ,有
\[a^p\equiv a(\bmod\ p)\Rightarrow \gcd(a,p)=1 \]前提:
- \(p\) 是质数
- \(gcd(a,p)=1\)
证明:
有数列\(S=\{1,2,3,\cdots p-1\}\),将 \(S\times a \Rightarrow \{a,2a,3a,\cdots,(p-1)a\}\)
\[(S\times a)\bmod\ p\ \Rightarrow\ \{a,2a,3a,\cdots,(p-1)a\}\bmod\ p\Rightarrow \{1,2,3,\cdots,p-1\} \](因为 \(\gcd(a,p)=1\),所以余数为1~p-1)
\[\prod_{i=1}^{p-1}i\equiv\prod_{i-1}^{p-1}a\times i\pmod p\\ (p-1)!\equiv a^{p-1}\times(p-1)!\pmod p\\ 1\equiv a^{p-1}\pmod p\\ a^{-1}\equiv a^{p-2}\pmod p\\ \] 标签:费马,pmod,定理,times,cdots,Rightarrow,bmod,equiv From: https://www.cnblogs.com/lldxjw/p/18004067