费马小定理
对于任意整数 a a a 与质数 p p p,有 a p ≡ a ( m o d p ) a^p\equiv a \pmod p ap≡a(modp)
两边约去 a a a,得: a p − 1 ≡ 1 ( m o d p ) a^{p-1}\equiv 1 \pmod p ap−1≡1(modp)
费马大定理
对于整数 n n n
若 n < 2 n<2 n<2 ,则方程 x n + y n = z n x^n+y^n=z^n xn+yn=zn 有满足 { x , y , z } \{x,y,z\} {x,y,z} 的解
否则没有
二次探测定理
对于任意奇素数 p p p,满足
x 2 ≡ 1 ( m o d p ) x^2\equiv 1 \pmod p x2≡1(modp)
的解仅有 x ≡ 1 x\equiv 1 x≡1 或 x ≡ p − 1 ( m o d p ) x\equiv p-1 \pmod p x≡p−1(modp)
x 2 ≡ 1 ( m o d p ) x^2\equiv 1 \pmod p x2≡1(modp)
x 2 − 1 ≡ 0 ( m o d p ) x^2-1\equiv 0 \pmod p x2−1≡0(modp)
( x + 1 ) ( x − 1 ) ≡ 0 ( m o d p ) (x+1)(x-1)\equiv 0 \pmod p (x+1)(x−1)≡0(modp)
x − 1 ( m o d p ) ≡ 0 x-1 \pmod p\equiv0 x−1(modp)≡0
x + 1 ( m o d p ) ≡ 0 x+1 \pmod p\equiv 0 x+1(modp)≡0
x ≡ 1 x\equiv 1 x≡1
x ≡ p − 1 ( m o d p ) x\equiv p-1\pmod p x≡p−1(modp)
二项式定理
( a + b ) n ≡ C n 0 a n + C n 1 a n − 1 b + C n 2 a n − 2 b 2 + ⋯ + C n n b n (a+b)^n\equiv C^0_na^n+C^1_na^{n-1}b+C^2_na^{n-2}b^2+\cdots+C_n^nb^n (a+b)n≡Cn0an+Cn1an−1b+Cn2an−2b2+⋯+Cnnbn
证明嘛,就不证了
Lucas 定理
首先我们有组合数的公式:
C n m = n ! m ! ( n − m ) ! C^m_n=\frac{n!}{m!(n-m)!} Cnm=m!(n−m)!n!
然后来证明一个东西:
∀ i ∈ [ 1 , p − 1 ] : C p i ≡ 0 ≡ p i C p − 1 i − 1 ( m o d p ) \forall i\in [1,p-1]:C^i_p\equiv 0\equiv \frac{p}{i}C^{i-1}_{p-1} \pmod p ∀i∈[1,p−1]:Cpi≡0≡ipCp−1i−1(modp)
∵ C p i = p ! i ! ( p − i ) ! = p i × ( p − 1 ) ! ( i − 1 ) ! ( p − i ) ! ∵ C_p^i=\frac{p!}{i!(p-i)!}=\frac{p}{i}\times\frac{(p-1)!}{(i-1)!(p-i)!} ∵Cpi=i!(p−i)!p!=ip×(i−1)!(p−i)!(p−1)!
∵ C p − 1 i − 1 = ( p − 1 ) ! ( i − 1 ) ! ( p − i ) ! ∵ C^{i-1}_{p-1}=\frac{(p-1)!}{(i-1)!(p-i)!} ∵Cp−1i−1=(i−1)!(p−i)!(p−1)!
∴ C p − 1 i − 1 × p i ≡ C p i ∴ C^{i-1}_{p-1}\times \frac{p}{i}\equiv C_p^i ∴Cp−1i−1×ip≡Cpi
由二项式定理得:
( 1 + x ) p ≡ C p 0 1 p + C p 1 1 p − 1 x + ⋯ + C p p x p (1+x)^p\equiv C_p^01^p+C^1_p1^{p-1}x+\cdots+C^p_px^p (1+x)p≡Cp01p+Cp11p−1x+⋯+Cppxp
( 1 + x ) p ≡ C p 0 1 p + C p p x p ≡ 1 + x p ( m o d p ) (1+x)^p\equiv C_p^01^p+C_p^px^p\equiv 1+x^p\pmod p (1+x)p≡Cp01p+Cppxp≡1+xp(modp)
令
a = k p + r , b = k ′ p + r ′ a=kp+r,b=k'p+r' a=kp+r,b=k′p+r′
求证
C a b ≡ C k p k ′ p × C r r ′ ( m o d p ) C_a^b\equiv C^{k'p}_{kp}\times C_{r}^{r'}\pmod p Cab≡Ckpk′p×Crr′(modp)
∵ ( 1 + x ) a = ( 1 + x ) k p × ( 1 + x ) r ∵ (1+x)^a=(1+x)^{kp}\times (1+x)^r ∵(1+x)a=(1+x)kp×(1+x)r
∵ ( 1 + x ) k p = ( ( 1 + x ) p ) k = ( 1 + x p ) k ( m o d p ) ∵ (1+x)^{kp}=((1+x)^p)^k=(1+x^p)^k \pmod p ∵(1+x)kp=((1+x)p)k=(1+xp)k(modp)
∴ ( 1 + x ) a = ( 1 + x p ) k × ( 1 + x ) r ( m o d p ) ∴ (1+x)^a=(1+x^p)^k\times (1+x)^r\pmod p ∴(1+x)a=(1+xp)k×(1+x)r(modp)
∵ C a b = C k p k ′ p × C r r ′ ( m o d p ) ∵ C_a^b=C^{k'p}_{kp}\times C^{r'}_r\pmod p ∵Cab=Ckpk′p×Crr′(modp)
∴ C a b x b = C k k ′ C r r ′ x k ′ p x r ′ ( m o d p ) ∴ C_a^bx^b=C^{k'}_kC^{r'}_rx^{k'p}x^{r'}\pmod p ∴Cabxb=Ckk′Crr′xk′pxr′(modp)
∴ C a b = C k k ′ C r r ′ ( m o d p ) ∴ C_a^b=C^{k'}_kC^{r'}_r\pmod p ∴Cab=Ckk′Crr′(modp)
∴ C a b = C k k ′ C r r ′ = C ⌊ a p ⌋ ⌊ b p ⌋ × C a m o d p b m o d p ( m o d p ) ∴ C_a^b=C^{k'}_kC^{r'}_r=C^{\lfloor\frac{b}{p}\rfloor}_{\lfloor\frac{a}{p}\rfloor}\times C^{b \mod p}_{a\mod p}\pmod p ∴Cab=Ckk′Crr′=C⌊pa⌋⌊pb⌋×Camodpbmodp(modp)
∴ Lucas ( a , b , p ) = C ⌊ a p ⌋ ⌊ b p ⌋ × C a m o d p b m o d p ( m o d p ) ∴ \text{Lucas}(a,b,p)=C^{\lfloor\frac{b}{p}\rfloor}_{\lfloor\frac{a}{p}\rfloor}\times C^{b \mod p}_{a\mod p}\pmod p ∴Lucas(a,b,p)=C⌊pa⌋⌊pb⌋×Camodpbmodp(modp)