找回密码
 欢迎注册
楼主: mathematica

[提问] 求F15后的第一个素数

[复制链接]
发表于 2022-9-19 15:16:24 | 显示全部楼层
试验了一下先筛选,在gmp概率素数测试,在我笔记本上,
test 10 cost 6s
test 20 cost 11s
test 30 cost 17s
test 40 cost 23s
test 50 cost 28s
test 60 cost 34s
test 70 cost 40s
test 80 cost 46s
test 90 cost 51s
test 100 cost 57s
test 110 cost 63s
test 120 cost 68s
test 130 cost 74s
test 140 cost 80s
test 150 cost 86s
test 160 cost 92s
M14+2774 found
test 170 cost 99s
test 180 cost 105s
test 190 cost 110s
test 200 cost 116s
test 210 cost 122s
test 220 cost 128s
100秒左右可以找到M14的解。但是M15大概每测试10个素数需要35s,预计测试6K左右个素数可以找到结果,预计需要6小时左右,和nyy的计算结果花费时间基本一个数量级

点评

nyy
你的想法是对的,用小素数筛快多了!  发表于 2022-9-19 17:05
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-19 15:54:21 | 显示全部楼层
mathe 发表于 2022-9-19 15:16
试验了一下先筛选,在gmp概率素数测试,在我笔记本上,
test 10 cost 6s
test 20 cost 11s

这个是F15之前的第一个素数=F15-25354,
这个间隔是25354呀,你6k怎么可能找到结果?看错了吗?

点评

比如M14,前面测试了160多个数,就可以找到M14+2774  发表于 2022-9-19 16:18
先快速筛选,可以淘汰掉多数候选数。我开的窗口是200000,筛选后余下不到10000个数。  发表于 2022-9-19 16:17
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-19 16:39:17 | 显示全部楼层
mathe 发表于 2022-9-19 15:16
试验了一下先筛选,在gmp概率素数测试,在我笔记本上,
test 10 cost 6s
test 20 cost 11s

你真聪明,居然用小素数筛选,我就比较笨了,我试了一下,用小素数筛选,确实快一些!
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-19 16:53:26 | 显示全部楼层
这个是F15后面的三个连续素数。
(2^(2^15)+1)+118112
(2^(2^15)+1)+143904
(2^(2^15)+1)+145026
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-19 16:56:52 | 显示全部楼层
再继续后面的两个素数:
(2^(2^15)+1)+160770
(2^(2^15)+1)+162872
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-19 17:05:02 | 显示全部楼层
再继续后面的两个素数:
(2^(2^15)+1)+182004
(2^(2^15)+1)+187860
F15后面的全部素数(7个)如下:
(2^(2^15)+1)+118112
(2^(2^15)+1)+143904
(2^(2^15)+1)+145026
(2^(2^15)+1)+160770
(2^(2^15)+1)+162872
(2^(2^15)+1)+182004
(2^(2^15)+1)+187860

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-20 07:07:09 | 显示全部楼层
  1. #include <gmpxx.h>
  2. #include <time.h>
  3. #include <stdio.h>
  4. #include <omp.h>

  5. #define FM 15
  6. #define TC 2
  7. #define TRANGE 10000000
  8. #define BLOCKSIZE 200000
  9. char isp[TRANGE];
  10. char bsize[BLOCKSIZE];

  11. void initp()
  12. {
  13.         int i;
  14.         for(i=2;i<TRANGE;i++)isp[i]=1;
  15.         for(i=2;i<=TRANGE/i;i++){
  16.                 if(isp[i]){
  17.                         int j;
  18.                         for(j=i*i;j<TRANGE;j+=i)isp[j]=0;
  19.                 }
  20.         }
  21. }

  22. int pow2n(int n, int p)
  23. {
  24.         long r=1,m=2;
  25.         int i;
  26.         while(n>0){
  27.                 if(n&1){
  28.                         r*=m;
  29.                         r%=p;
  30.                 }
  31.                 m*=m;
  32.                 m%=p;
  33.                 n>>=1;
  34.         }
  35.         return (int)r;
  36. }

  37. void init()
  38. {
  39.         int i,p;
  40.         int n=1<<FM;
  41.         initp();
  42.         for(i=1;i<BLOCKSIZE;i++)bsize[i]=1;
  43.         for(p=2;p<TRANGE;p++){
  44.                 if(!isp[p])continue;
  45.                 int r=pow2n(n,p);
  46.                 for(i=p-r;i<BLOCKSIZE;i+=p){
  47.                         bsize[i]=0;
  48.                 }
  49.         }
  50.         int c=0;
  51.         for(i=1;i<BLOCKSIZE;i++){
  52.                 if(bsize[i])c++;
  53.         }
  54.         printf("Total %d cands left\n",c);
  55. }

  56. int gc;
  57. int main()
  58. {
  59.         int i;
  60.         time_t start = time(NULL);
  61.         init();
  62.         printf("Init done\n");fflush(stdout);
  63.         mpz_class x=1;
  64.         x<<=1<<FM; //2^(2^FM)
  65. #pragma omp parallel for
  66.         for(i=1;i<BLOCKSIZE;i++){
  67.                 if(!bsize[i])continue;
  68.                 mpz_class y=x+i;
  69.                 gc++;
  70.                 if(mpz_probab_prime_p(y.get_mpz_t(),TC)){
  71.                         printf("M%d+%d\n",FM,i-1);
  72.                         fflush(stdout);
  73.                         fprintf(stderr,"M%d+%d found\n",FM,i-1);
  74.                 }
  75. #if 0
  76.                 if(gc%7==0){
  77.                         int diff = time(NULL)-start;
  78.                         fprintf(stderr,"test %d cost %ds\n",gc,diff);
  79.                 }
  80. #endif
  81.         }
  82.         return 0;
  83. }
复制代码

点评

nyy
你的代码真的太干净了,一句注释都没有!  发表于 2022-9-20 09:00
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-20 09:08:37 | 显示全部楼层
今天争取搞出F16后面的第一个素数!仅仅只是争取,也许间距很大,但是争取搞出来!
8:29开始找,但是到现在还没找到。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-20 09:26:08 | 显示全部楼层
F16后面的两个素数:由于两个素数靠得比较近,所以我就一起贴上来。
(2^(2^16)+1)+44060
(2^(2^16)+1)+44180
找到9:23终于找到一个,耗时54分钟!

点评

nyy
(2^(2^16) + 1) + 44180 // PrimeQ // Timing {102.461, True}  发表于 2022-9-20 09:32
nyy
(2^(2^16) + 1) + 44060 // PrimeQ // Timing {102.29, True}  发表于 2022-9-20 09:32
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2022-9-20 13:51:07 | 显示全部楼层
F16前的第一个素数是
(2^(2^16)+1)-5628
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-23 16:23 , Processed in 0.088299 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表