摘要: 素数筛法是这样的: 1.开一个大的bool型数组prime[],大小就是n+1就可以了.先把所有的下标为奇数的标为true,下标为偶数的标为false. 2.然后: for( i=3; isqrt(30)算法结束。 第 3 步把prime[]值为true的下标输出来: for(i=2; isqrt... 阅读全文
posted @ 2015-04-06 14:57 Spiderman.L 阅读(167) 评论(0) 推荐(0) 编辑
摘要: int gcd(int a,int b){ int temp; if(a<b){/*交换两个数,使大数放在a上*/ temp=a; a=b; b=temp;}while(b!=0){/*利用辗除法,直到b为0为止*/ temp=a%b; a=b; b=temp; } return a;}int is... 阅读全文
posted @ 2015-04-06 10:11 Spiderman.L 阅读(621) 评论(0) 推荐(0) 编辑