Group Abstract Group Abstract

Message Boards Message Boards

1
|
2.4K Views
|
0 Replies
|
1 Total Like
View groups...
Share
Share this post:
GROUPS:

Optimus Primes

Posted 10 years ago

At Stack Exchange I saw the problem prime where deleting any digit yields a prime. In OEIS, it's sequence A034302, which starts 23, 37, 53, 73, 113, 131, 137, 173, 179, 197, 311, 317, 431, 617, 719, 1499. The maximum solution on mathSE page had 11 digits, and I was pretty sure I could beat that.

ThreeDigits[{a_, b_, c_, x_, y_, z_}] := FromDigits[Flatten[{Table[a, {x}], Table[b, {y}], Table[c, {z}]}]]  

blah = Select[Select[Tuples[Range[0, 9], {3}], MemberQ[{1, 3, 7, 9}, #[[3]]] && #[[1]] != 0 && 
GCD @@ # == 1 &], #[[1]] != #[[2]] && #[[2]] != #[[3]] &];

sols = Monitor[Select[Table[{blah[[index]], Select[Tally[Last /@ Select[Subsets[Drop[#, 1] & /@ 
     Select[Flatten[Table[{PrimeQ[ThreeDigits[Flatten[{blah[[index]], x, y, z}]]], x, y,z}, {x, 1, 15}, {y, 1, 15}, {z, 1, 15}], 
      2], #[[1]] == True &], {2}], EuclideanDistance[#[[1]], #[[2]]] == 1 &]], Last[#] > 2 &]}, {index, 1, 
      Length[blah]}], #[[2]] != {} &], {index, x, y, z}]

Sort[ThreeDigits[Drop[Flatten[#], -1]] & /@ sols]

That gives {22255999, 1133333777, 999996677777777777, 66666666666666622222222222222333, 77777777999999999999999777777777}. Two solutions with 32 digits! I beat that page!

Unfortunately, I then did a Google search on that 623 number, and that led to Codegolf --Find largest prime which is still a prime after digit deletion. There, in addition to my solutions, user primo found

444444444444444444444444444444444444444444444444441111111113333333333333333333333333 -- 83 digits

and

4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111 -- 274 digits

The code I used doesn't scale up well, so I'm not sure how to beat those results.

POSTED BY: Ed Pegg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard