随笔分类 - 数学-素数
摘要:Prime Distance Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the inter
阅读全文
摘要:费尔马小定理:如果p是一个素数,且0<a<p,则a^(p-1)%p=1.利用费尔马小定理,对于给定的整数n,可以设计素数判定算法, 通过计算d=a^(n-1)%n来判断n的素性,当d!=1时,n肯定不是素数,当d=1时,n 很可能是素数. 二次探测定理:如果是素数,且,则方程的解为或。 利用二次探测
阅读全文
摘要:The sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbe
阅读全文
摘要:以前求0~n之内的素数是一个一个的判断,时间复杂度是O(n^2),速度很慢。 而今天讲的这种方法速度快多了,时间复杂度是nlong(n),模板如下: 1 a[0] = a[1] = 1; 2 for(int i = 2; i <= MAXN; i++){ 3 if(!a[i]){ 4 for(int
阅读全文