Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #28 Oct 05 2020 14:08:24
%S 19,23,29,41,43,47,53,59,61,67,83,89,173,271,277,313,379,397,419,479,
%T 491,571,577,593,617,631,673,811,839,877,911,977,1777,1913,2131,2311,
%U 2377,2399,2713,2791,2939,2971,4177,4339,4919,4993,5119,5791,6133,6737,6997,7193,7333,7919,8111
%N Primes p where all the cyclic shifts of their digits to the right also produce primes except the last one before reaching p again.
%C a(125)=937337931113, a(126) is larger than 10^16 (if it exists).
%H Chai Wah Wu, <a href="/A286415/b286415.txt">Table of n, a(n) for n = 1..125</a>
%e 2131 is a member as all the cyclic shifts of its digits to the right result in primes (1213, 3121) except the last one (1312) before reaching the original prime.
%t cyclDigs[k_]:= FromDigits/@ NestList[RotateRight, IntegerDigits[k], IntegerLength[k]-1]; rgtSftNearCircPrmsInBtw[m_, n_]:= ParallelMap[ If[AllTrue[Most[cyclDigs[#]], PrimeQ] && Not@ PrimeQ[Last[cyclDigs[#]]], #, Nothing] &, Prime @ Range[PrimePi[m], PrimePi[n]]];
%t rgtSftNearCircPrmsInBtw[19, 10^7]
%t cspQ[n_]:=Module[{t=PrimeQ[FromDigits/@Table[RotateRight[IntegerDigits[ n],k],{k,IntegerLength[n]-1}]]},Last[t]==False&&Union[Most[t]]=={True}]; Join[ {19,23,29,41,43,47,53,59,61,67,83,89},Select[ Prime[ Range[ 26,1100]],cspQ]] (* _Harvey P. Dale_, Oct 05 2020 *)
%o (Python)
%o from itertools import product
%o from sympy import isprime
%o A286415_list = []
%o for l in range(1,15):
%o for d in '123456789':
%o for w in product('1379',repeat=l):
%o s = d+''.join(w)
%o n = int(s)
%o for i in range(l):
%o if not isprime(int(s)):
%o break
%o s = s[-1]+s[:-1]
%o else:
%o if not isprime(int(s)):
%o A286415_list.append(n) # _Chai Wah Wu_, May 21 2017
%Y Cf. A270083 (subsequence of), A286333.
%K nonn,base
%O 1,1
%A _Mikk Heidemaa_, May 08 2017