Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created May 1, 2024 21:38
Show Gist options
  • Save Hermann-SW/fbcfe5ea27aa0d36a1f118439154119b to your computer and use it in GitHub Desktop.
Save Hermann-SW/fbcfe5ea27aa0d36a1f118439154119b to your computer and use it in GitHub Desktop.
20 palindrome primes from t5k.org
{[
"10^2000007-10^1127194-10^872812-1",
"10^2000005-10^1051046-10^948958-1",
"10^1888529-10^944264-1",
"10^1234567-20342924302*10^617278-1",
"10^1234567-1927633367291*10^617277-1",
"10^1234567-3626840486263*10^617277-1",
"10^1234567-4708229228074*10^617277-1",
"10^490000+3*(10^7383-1)/9*10^241309+1",
"10^474500+999*10^237249+1",
"10^400000+4*(10^102381-1)/9*10^148810+1",
"10^390636+999*10^195317+1",
"10^362600+666*10^181299+1",
"10^320236+10^160118+1+(137*10^160119+731*10^159275)*(10^843-1)/999",
"10^320096+10^160048+1+(137*10^160049+731*10^157453)*(10^2595-1)/999",
"10^314727-8*10^157363-1",
"10^300000+5*(10^48153-1)/9*10^125924+1",
"10^290253-2*10^145126-1",
"10^283355-737*10^141676-1",
"10^275494+10^137747+1+(137*10^137748+731*10^129293)*(10^8454-1)/999",
"10^269479-7*10^134739-1"
]}
@Hermann-SW
Copy link
Author

palin.gp verifies that all 20 numbers are palindomes, and then identifies the only two such primes with p±2 not having small divisor (candidates for twin prime with p):

P=readvec("palindrome.gp")[1];
foreach(P,s,p=eval(s);print1(digits(p)==Vecrev(digits(p))))
{
  foreach(P,s,p=eval(s);
    p+=if(p%3==1,-2,2);
    comp=0;
    forprime(q=2,1000000,
      if(p%q==0,comp=1;break();)
    );
    if(!comp,print(p-eval(s)," ",s));
  )
}
$ gp -q < palin.gp 
11111111111111111111
2 10^490000+3*(10^7383-1)/9*10^241309+1
2 10^320236+10^160118+1+(137*10^160119+731*10^159275)*(10^843-1)/999
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment