威尔逊定理

威尔逊定理给出当且仅当p为素数时:( p -1 )! ≡ -1 ( mod p )

充分性证明:

如果“p”不是素数,那么它的正因数必然包含在整数1, 2, 3, 4, … ,p− 1 中,因此gcd((p− 1)!,p) > 1,所以我们不可能得到(p− 1)! ≡ −1 (mod p)。

必要性证明:

取集合A={1,2,3,...,p-1};则任意i属于A,且存在j属于A,使得:(ij)恒等于1(mod p)

设x*a ≡ 1 (mod p)。

除了x=a时,a*a≡1 (mod p),

(a+1)*(a-1)≡ 0 (mod p),

a=1或a=p-1 ,不成立。

其他情况都可以找到对应的a。

所以(p-1)!≡1*(p-1)(mod p)≡-1 (mod p)

时间: 2024-08-28 15:26:44

威尔逊定理的相关文章

数论·威尔逊定理

威尔逊定理: $(p-1)!\equiv -1(\mod p)$当且仅当$p$为素数. 证明:在模p(素数)的简化剩余系$S = \{1, 2, ..., p - 1\}$中,对任意$i\in S$, $\exists j$, $ s.t.$,  $ij \equiv 1(\mod p)$, 考虑这种性质具有对称性,若${i^2}\equiv1(\mod p)$,则$i\equiv{\pm1}({\mod p})$,因此$(p-1)!\mod p = 1(p-1)\mod p = -1$.

【转】威尔逊定理

[转]威尔逊定理 威尔逊定理:,其中p为素数. 题目:给定一个正整数n,求表达式:的值. 分析:分两种情况讨论. (1)3k+7为素数时,那么由威尔逊定理知道,即 此时有,,所以 (2)3k+7为合数时,那么3k+7可以写成:,那么很明显a和b在(3k+6)!中都会出现, 所以,此时 所以,综上,问题就是小于等于n的数i中,存在多少个i,使得3i+7是素数.

[UVA1434] YAPTCHA(数论,威尔逊定理)

题目链接:http://acm.hust.edu.cn/vjudge/problem/36250 题意:求那个式子. 设3k+7=x,则化简成 Sn=Σ(k=1~n) (((x-1)!+1/x)-[(x-1)!/x]) 根据威尔逊定理,假如一个数p是素数,则这个数满足:(p-1)!=-1 (mod p)即 (p-1)!-1=0(mod p). 由于被减数满足此条件,而减数表示向下取整.则被减数整除,减数一定是向下取整的.所以结果减数比被减数要小1,否则减数和被减数相等,即为0.问题转换成了求3k

hdu5391 Zball in Tina Town(威尔逊定理)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 219    Accepted Submission(s): 144 Problem Description Tina Town i

hdu5391威尔逊定理

威尔逊定理 在初等数论中,威尔逊定理给出了判定一个自然数是否为素数的充分必要条件.即:当且仅当p为素数时:( p -1 )! ≡ -1 ( mod p ),但是由于阶乘是呈爆炸增长的,其结论对于实际操作意义不大. hdu5391用到了这一数论定理. Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s):

威尔逊定理x

威尔逊定理 在初等数论中,威尔逊定理给出了判定一个自然数是否为素数的充分必要条件.即:当且仅当p为素数时:( p -1 )! ≡ -1 ( mod p ),但是由于阶乘是呈爆炸增长的,其结论对于实际操作意义不大. 充分性 如果“p”不是素数,那么它的正因数必然包含在整数1, 2, 3, 4, … ,p− 1 中,因此gcd((p− 1)!,p) > 1,所以我们不可能得到(p− 1)! ≡ −1 (modp). 必要性 若p是素数,取集合 A={1,2,3,...p -1}; 则A 构成模p乘法

威尔逊定理的应用

题目: 求 (n-1)!mod(n)的值. 很显然当 n 是合数时  结果为0(当然这里有个特例4) 当 n 为素数时, 直接用 威尔逊定理 结果为n-1. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #define LL long long using namespace std; bool is_prime(LL n) { for(int i=2; i*i&l

UVA - 1434 YAPTCHA (威尔逊定理)

Description The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-PublicTuring-Test-to-Tell-Computers-and-Humans-Apart on t

hdu2973 YAPTCHA【威尔逊定理】

<题目链接> 题目大意: The task that is presented to anyone visiting the start page of the math department is as follows: given a natural n, compute  where [x] denotes the largest integer not greater than x. 给出 t 和n,t代表样例组数,根据给出的n算出上面表达式.(注意:[x]表示,不超过x的最大整数)