Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #31 Mar 14 2020 13:18:31
%S 11,3,5,7,919,11,13,0,17,19,21121,23,0,27127,29,31,33533,0,37,39139,
%T 41,43,0,47,49549,51151,53,0,57457,59,61,63463,0,67,690269,71,73,0,
%U 77377,79,81181,83,0,87187,89,91291,93493,0,97
%N Smallest prime beginning and ending in 2n+1 or 0 if no such prime exists.
%C If the two copies of the 2n+1 are not allowed to share digits, a(1) is not 3, a(2) is not 5 and a(3) is not 7 and a(5) is not 11, which results in A070278.
%C Conjecture: a(n) = 0 if and only if n > 2 and n == 2 mod 5 (which makes 2*n+1 == 0 mod 5). - _Robert Israel_, May 26 2015
%H Alois P. Heinz, <a href="/A071234/b071234.txt">Table of n, a(n) for n = 0..10000 </a>
%e a(6060) = 1212121, because it is the smallest prime beginning and ending in 2*6060+1 = 12121.
%e a(7+5*k) = 0, because 2*(7+5*k)+1 = 15+10*k == 0 (mod 5) is no prime.
%p A071234 := proc(n)
%p local dgsn ,p,wrks,doff;
%p dgsn := convert(2*n+1,base,10) ;
%p for i from 1 to 1000000 do
%p p := ithprime(i) ;
%p wrks := true;
%p dgsp := convert(p,base,10) ;
%p doff := nops(dgsp)-nops(dgsn) ;
%p if doff >= 0 then
%p for d from 1 to nops(dgsn) do
%p if op(d,dgsp) <> op(d,dgsn) then
%p wrks := false;
%p break;
%p end if;
%p if op(d+doff,dgsp) <> op(d,dgsn) then
%p wrks := false;
%p break;
%p end if;
%p end do:
%p if wrks then
%p return p
%p end if;
%p end if;
%p end do:
%p return 0 ;
%p end proc: # _R. J. Mathar_, Feb 03 2011
%p # Alternative:
%p f:= proc(n)
%p local u,d,r,x,y;
%p u:= 2*n+1;
%p if isprime(u) then return(u) fi;
%p if u mod 5 = 0 then return(0) fi;
%p d:= ilog10(u);
%p for r from 0 do
%p for x from 0 to 10^(r+1)-1 do
%p y:= u + 10^(d+1)*x + 10^(r+d+2)*u;
%p if isprime(y) then return(y) fi
%p od od
%p end proc:
%p 11, seq(f(n), n=1..100); # _Robert Israel_, May 26 2015
%o (Sage)
%o def A071234(n):
%o s = str(2*n+1)
%o if s.endswith('5') and not s == '5': return 0
%o for p in Primes():
%o ps = str(p)
%o if ps.startswith(s) and ps.endswith(s): return p
%o [A071234(n) for n in range(20)]
%o # _D. S. McNeil_, Feb 03 2011
%Y Cf. A070278.
%K nonn,base
%O 0,1
%A _Amarnath Murthy_, May 18 2002