# 费马小定理&欧拉定理&扩展欧拉定理(欧拉降幂)

#### 费马小定理

##### 定理：

p p 为质数且 p p a a 互质那么就有 a p − 1 ≡ 1 ( m o d    p ) a^{p - 1}\equiv1(\mod p)

##### 证明：

a p = ( a − 1 + 1 ) p a^p = (a - 1 + 1)^p

a p = ( a − 1 ) p + C p 1 ( a − 1 ) p − 1 + . . . + 1 a^p = (a - 1)^p + C_{p}^1(a - 1)^{p -1} + ...+1

1. a p ≡ ( a − 1 ) p + 1 ( m o d    p ) a^p\equiv(a - 1)^p + 1(\mod p)

a p ≡ a ( m o d    p ) a^p \equiv a (\mod p)

p ∣ a p − 1 − 1 p|a^{p - 1} - 1

#### 欧拉定理

##### 证明

P = { x ∣ g c d ( x , p ) = 1 且 1 ≤ x ≤ p } P = \{x|gcd(x,p) =1且1 \le x \le p \}
Q = { a x ∣ x ∈ P } Q = \{ax|x \in P\}

a x 2 − a x 1 = a ( x 2 − x 1 ) ax_2 - ax_1 = a(x_2 - x_1) 由于 x 1 , x 2 < p x_1,x_2 < p 所以 ( x 2 − x 1 ) (x_2 - x_1) 不能被p整除，故Q中元素在模p的意义下各不相同

a ϕ ( p ) ≡ 1 ( m o d    p ) a^{\phi(p)} \equiv 1(\mod p)

#### 扩展欧拉定理：

a b ≡ { a b m o d    ϕ ( p )                          ( g c d ( a , p ) = 1 ) a b                       ( g c d ( a , p ) ! = 1 , b < ϕ ( p ) ) a b m o d    ϕ ( p ) + ϕ ( p ) ( g c d ( a , p ) ! = 1 , b ≥ ϕ ( p ) ) ( m o d    p ) a^b\equiv\left\{ \begin{array}{c} {a^{b \mod \phi (p)}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (gcd(a,p) =1)}\\ {a^b \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (gcd(a,p)!=1,b < \phi(p))}\\ {a^{b \mod \phi (p) + \phi(p)}(gcd(a,p)!=1,b \ge \phi(p))} \end{array} \right. (\mod p)
a b ≡ a % p b % p ( m o d    p ) \frac{a}{b} \equiv \frac{a\%p}{b\% p}(\mod p)

11-09 145
11-01 105

02-21 9213
08-01 104
04-06 294
06-14 1万+
07-30 653
01-29 148