login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A228566 a(n) is the smallest prime of more than n digits such that the number formed by first n digits is same as the number formed by last n digits. 1

%I #6 Aug 26 2013 01:31:28

%S 11,11311,18181,1041041,1212121,1125112511,323232323,13513513513,

%T 12121212121,1021021021021,17417417417417,11005110051100511,

%U 151515151515151,11411411411411411,38383838383838383,1041041041041041041,1111111111111111111,1111111111111111111

%N a(n) is the smallest prime of more than n digits such that the number formed by first n digits is same as the number formed by last n digits.

%H Giovanni Resta, <a href="/A228566/b228566.txt">Table of n, a(n) for n = 1..100</a>

%e a(4) = 1041041 because 1041041 is the smallest prime with more than 4 digits that starts and ends with the same 4-digit number (here 1041).

%t ric[ps_, w_] := Catch[Block[{n, d, r}, If[w == {}, Throw@If[PrimeQ[n = FromDigits@ps], n, 0], Do[If[(r = ric[ps /. w[[1, 1]] -> d, Rest@w]) > 0, Throw[r]], {d, w[[1, 2]]}]]; 0]]; try[nd_, k_] := Block[{v = Array[x, nd], w, s}, s = v /. ToRules@ Reduce[Take[v, k] == Take[v, -k]]; w = Table[{e, If[e === s[[-1]], {1, 3, 7, 9}, If[e === s[[1]], Range@9, Range[0, 9]]]}, {e, DeleteDuplicates@ s}]; ric[s, w]]; a[n_] := Block[{nd = n+1, v=0},

%t While[(v = try[nd, n]) == 0, nd++]; v]; Array[a, 20]

%Y Cf. A228533.

%K nonn,base

%O 1,1

%A _Giovanni Resta_, Aug 25 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 18 01:34 EDT 2024. Contains 374377 sequences. (Running on oeis4.)