#include #include #include #include #include #include #include #include #include #include #include #include #define cyclemax 6 using namespace std; // code base mxlg [d1[@d2] [d3[@d4]]] // tries to extend the current kernel for base with primes up to length mxlg // if d1 is specified, we only consider families starting with digit d1 (up to d2 if specified) // if d3 is specified, we only consider families ending with digit d3 (up to d4 if specified) // new found primes are gathered in a file newprimes{base}-suffix // and families to be still analyzed are gathered in a file left{base}-suffix // details of the exploration are send to the standard output char tr[128]; int w[128]; using family=vector ; using sint=long unsigned int; // std::vector >::size_type; vector found; ifstream kern; ofstream result,reject,court; sint b; vector fact; string covering; clock_t cpustarttime,cputime; mpz_class nt,nprime,nlong,n1; sint k,lgmax,nbsmall; mpz_t rtt,rt1,rt2; random_device rd; mt19937 gen(rd()); // set random gen string s10(mpz_class x) {mpz_class y=x; int r; string s=""; while (y!=0){r=mpz_class{y%10}.get_si();y=y/10;s=tr[r]+s;} return s; } string sb(mpz_class x) {mpz_class y=x; int r; string s="";if(x==0)return "0"; while (y!=0){r=mpz_class{y%b}.get_si();y=y/b;s=tr[r]+s;} return s; } string familystrip(family f) {string ss; sint i; ss=""; for(i=0;ii){ii=j;jj=i;} else {ii=i;jj=j;} while(jj!=0){kk=ii%jj;ii=jj;jj=kk;} return ii;} mpz_class gcd(mpz_class i,mpz_class j) {mpz_class ii,jj,kk; if(i==0)return j;if(j==0)return i; if(j>i){ii=j;jj=i;} else {ii=i;jj=j;} while(jj!=0){kk=ii%jj;ii=jj;jj=kk;} return ii;} int min( int i, int j) {if(i<=j)return i;else return j;} void buildfact() {sint kk,n; bool ok; fact.push_back(2);fact.push_back(3);fact.push_back(5); for(n=7;n=(found[it]).length()){covering=found[it];return true;} if(i>=el.length())break; } else {i++;if(i>=el.length())break;} } } return false; } bool newprime(string s) {sint i; mpz_class n1=0; for(i=0;i0) {nprime++;court<((b-1)/gg); if(test) {cout<((b-1)/gg); if(test) {cout<((bb-1)/gg); if(test) {cout<1&&difpowbb(ff[0],sddk,ff[2])) {cycles[j]="diff of kth powers";continue;} if((k==2||k==4)&&p4p4p4bb(ff[0],sddk,ff[2])) {cycles[j]="Germain's rule";continue;} break; } if(j==k){cout<<" cycle of factors of length "<\n"; for(j1=0;j1<2;j1++) {cout<<"[";for(j2=0;j2<2;j2++){cout<<"(";for(j3=0;j3<2;j3++)cout< ";cout<lgmax){cout<<"still to analyze (too long)\n";nlong++; reject<=lc2)continue; ff[i1-1]=f[i1-1]+p2+p1;s=familystrip(ff); if(!cover(s))continue; if(l=lc2)continue; ic1=i1;ic2=i2;jc1=j1;jc2=j2;lc2=l; } // handle selection if(lc2>=lc1) // no pair is really interesting {if(lc1==1000) // no digit is really selected: chose one randomly {test=false; if(f.size()>3){l=f.size()/2;uniform_int_distribution<> distri(0,l-1);test=true; ic=1+2*(distri(gen));} if(f[ic].length()>1){uniform_int_distribution<> distrj(0,f[ic].length()-1);jc=distrj(gen);test=true;} if(test)cout<<"! "<3){chunkl=argv[3];ms=ms+'-'+argv[3];}else{chunkl="";} if(argc>4){chunkr=argv[4];ms=ms+'-'+argv[4];}else{chunkr="";} pref="result"; prefms=pref+ms; result.open(prefms.c_str(),ios::out); pref="newprimes"; prefms=pref+ms; court.open(prefms.c_str(),ios::out); pref="left"; prefms=pref+ms; reject.open(prefms.c_str(),ios::out); for(char c='0';c<='9';c++){w[c]=0+c-'0';tr[0+c-'0']=c;} for(char c='A';c<='Z';c++){w[c]=10+c-'A';tr[10+c-'A']=c;} for(char c='a';c<='z';c++){w[c]=36+c-'a';tr[36+c-'a']=c;} buildfact(); if(chunkl!="")cout<<" for initial digits "<>p) {found.push_back(p); } // initialisation if(chunkl==""){ilb=1;ilh=b-1;} else {for(i=0;i