![]() |
|
|
#1 |
|
1976 Toyota Corona years forever!
"Wayne"
Nov 2006
Saskatchewan, Canada
124416 Posts |
What is the largest prime number you can find such that all groupings of numbers in order are also prime....
For example in the prime 373 all the following in () are also prime (3)73, 3(7)3, 37(3), (37)3, 3(73) Obviously it can only contain the digits 2, 3, 5, 7 I believe the first 5 non-trivial are: 23, 37, 53, 73, 373, |
|
|
|
|
|
#2 |
|
Jun 2003
22×3×421 Posts |
And those are the only solutions :-(
To create an n-digit solution, you need an n-1 digit solution and extend it by prefixing or suffixing another digit. 2 and 5 can only go as leading digit. Same digit cannot occur consecutively. With these restrictions, we see that the four 2-digit solutions and the one 3-digit solution are the only ones possible. 373 is a dead end. It cannot be extended further. |
|
|
|
|
|
#3 |
|
1976 Toyota Corona years forever!
"Wayne"
Nov 2006
Saskatchewan, Canada
22·7·167 Posts |
...
|
|
|
|
|
|
#4 |
|
"Antonio Key"
Sep 2011
UK
32·59 Posts |
I offer 1373
![]() (Ok, so I know 1 isn't strictly prime, but then it's not composite so there are no composites in any of the groupings.) Last fiddled with by Antonio on 2015-05-12 at 18:17 |
|
|
|
|
|
#5 |
|
Jun 2014
23×3×5 Posts |
|
|
|
|
|
|
#6 |
|
"Antonio Key"
Sep 2011
UK
32·59 Posts |
|
|
|
|
|
|
#7 |
|
Romulan Interpreter
Jun 2011
Thailand
961110 Posts |
Actually, let's allow 1 into it, to make it a bit more.. attractive. This way, you can have a 1 here and there, and even two of 1, as 11, 13, 17, 31, 71, are all prime... How high can you go?
|
|
|
|
|
|
#8 |
|
1976 Toyota Corona years forever!
"Wayne"
Nov 2006
Saskatchewan, Canada
22×7×167 Posts |
3137
your turn...hint no more of 4-digits Last fiddled with by petrw1 on 2015-05-15 at 17:13 |
|
|
|
|
|
#9 |
|
Romulan Interpreter
Jun 2011
Thailand
7×1,373 Posts |
Ha! I made you lose 20 minutes from your DC time! Every time you lose is a gain for me, so I can overtake you in the DC top..
![]() Joking apart (not!), I was too lazy/stupid to think (and anyhow one needs a calculator/computer to check the primality of 4-digits and more numbers), so I decided to write a pari/gp script, which took me about the same amount of time. Unfortunately I can't argue against you since my script says you are right... what a pity... ![]() These are all the solutions: Code:
gp > \r digits %xx = List([1, 2, 3, 5, 7]) time = 4 ms. %xx = List([1, 2, 3, 5, 7, 11, 13, 17, 23, 31, 37, 53, 71, 73, 113, 131, 137, 173, 311, 313, 317, 373, 1373, 3137]) gp > :hehe:)Code:
adg(digit=1, size=1)=
{
my(cnt=0,k,n,t,isp,ls);
for(i=1,#glist,
n=glist[i];
if(10^(size-1)<=n && n<10^size,
/*add on the back*/
k=1;
isp=1;
while(isp && k<=n,
k*=10;
if(!isprime((n%k)*10+digit),
isp=0
)
);
if(isp,
ls=#glist;
listput(glist,n*10+digit);
listsort(glist,1);
if(ls!=#glist,
cnt++
)
);
/* add on the front */
k=ceil(log(n)/log(10));
if(n==1,k=1);
t=k;
isp=1;
while(isp && k>0,
if(!isprime(digit*10^k+floor(n/10^(t-k))),
isp=0
);
k--
);
if(isp,
ls=#glist;
listput(glist,digit*10^t+n);
listsort(glist,1);
if(ls!=#glist,
cnt++
)
)
)
);
cnt
};
adigi(maxsize=8)=
{
my(s,ls);
for(size=1,maxsize,
until(s==0,
s=0;
forstep(i=1,7,2,
ls=#glist;
s=max(s,adg(i,size));
if(ls!=#glist,
print(glist)
)
);
ls=#glist;
s=max(s,adg(2,size));
if(ls!=#glist,
print(glist)
)
)
)
};
glist=List([1,2,3,5,7])
adigi()
glist
Last fiddled with by LaurV on 2015-05-16 at 09:08 |
|
|
|