View Single Post
 2021-01-01, 22:31 #1 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 22·503 Posts Happy New Year & There are just not enough Numerological Threads Code:  \\\\DSN-320-A-Pari-GP Code By Rashid Naimi 1/1/2121 >>>>>>>>>>>>>>>Error caught by Krisel. Now I have to reweight all the post dated checks for the year primeCounter=0 compositeCounter=0 LowP=101 highP=-1 for(n=1,19^19,{\\\\\\\\\\\\\\\\\\\\\\\\\\ n1=2*n; n2=(2+n*2)*n/2; addend0=6; m0=3; addend1=(n2+1-m0)*2+addend0; addend2=addend1+1; p=addend1*2+1; lowerFactor1=(p-1)/2; upperFactor1 = lowerFactor1+1; mLower1 = Mod(lowerFactor1,p); mLower1 = mLower1 *lowerFactor1; mUpper1 = Mod(upperFactor1,p); mUpper1 = mUpper1*upperFactor1; lowerFactor1=lowerFactor1+1; upperFactor1 = upperFactor1-1; primeFlag=1; theDepth=1+2^14; \\\\\\ the larger this value, the less composites will pass the test. if(theDepth>(p-1)/2,theDepth=(p-1)/2); for(j=1,theDepth, lowerFactor1=lowerFactor1-1; upperFactor1 = upperFactor1+1; \\mLower1 = mLower1/lowerFactor1; iferr(mLower1 = mLower1/lowerFactor1, E, mLower1 =0;primeFlag=0;); \\mUpper1 = mUpper1/upperFactor1; iferr(mUpper1 = mUpper1/upperFactor1, E, mUpper1 =0;primeFlag=0;); ); if(!primeFlag, next(1); , print("\nn = ",n); print("n1 = ",n1); print("n2 = ",n2); print("p = ",p," >> ", ispseudoprime(p)); print("**** ",LowP,"% < ",prcntg,"% < ",highP,"% Prime!"); ); if(!ispseudoprime(p), if(primeFlag, \\next(19); \\Uncomment this line to abort on 1st test failiure ); ); if(ispseudoprime(p),primeCounter=primeCounter+1,if(primeFlag,compositeCounter=compositeCounter+1)); prcntg =round(primeCounter/(primeCounter+compositeCounter)*100); if(prcntg < LowP,LowP=prcntg); if(prcntg > highP,highP=prcntg); }) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\^^^^^^^^^^^^^^^^^^ I will let you figure out why it does what it does. I am only off by 100 years. ETA: Hint #1: It is based on Wilson's Theorem: https://en.wikipedia.org/wiki/Wilson%27s_theorem Last fiddled with by a1call on 2021-01-01 at 23:23