OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
MATHEMATICA
Select[Prime@Range@10000, (n=#; s={EvenQ, OddQ}; t=Take[IntegerDigits@n, {#}]&/@Select[Range@i, #]&/@If[EvenQ[i=IntegerLength@n], s, Reverse@s]; Union@Flatten@First@t=={1}&&FreeQ[Flatten@Last@t, 1])&] (* Giorgos Kalogeropoulos, Oct 22 2021 *)
eod1Q[p_]:=Module[{r=Reverse[IntegerDigits[p]]}, Union[Take[r, {1, -1, 2}]]=={1}&&FreeQ[ Take[ r, {2, -1, 2}], 1]]; Select[Prime[Range[2000]], eod1Q] (* Harvey P. Dale, May 28 2023 *)
PROG
(Python)
from sympy import primerange as primes
def ok(p):
s = str(p)
if not all(s[i] == '1' for i in range(-1, -len(s)-1, -2)): return False
return all(s[i] != '1' for i in range(-2, -len(s)-1, -2))
print(list(filter(ok, primes(1, 16142)))) # Michael S. Branicky, Oct 22 2021
(Python) # faster version for generating large initial segments of sequence
from sympy import isprime
from itertools import product
def eo1(maxdigits): # generator for every other digit is 1, no other 1's
yield 1
for d in range(2, maxdigits+1):
if d%2 == 0:
for f in "23456789":
f1 = f + "1"
for p in product("023456789", repeat=(d-1)//2):
yield int(f1 + "".join(p[i]+"1" for i in range(len(p))))
else:
for p in product("023456789", repeat=(d-1)//2):
yield int("1" + "".join(p[i]+"1" for i in range(len(p))))
print(list(filter(isprime, eo1(5)))) # Michael S. Branicky, Oct 22 2021
(Magma) f1:=func<n|forall{i:i in [1..#Intseq(n) by 2]| Intseq(n)[i] eq 1}>; fc:=func<n|forall{i:i in [2..#Intseq(n) by 2]| Intseq(n)[i] ne 1}>; [p:p in PrimesUpTo(17000)|f1(p) and fc(p)]; // Marius A. Burtea, Oct 22 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Lars Blomberg, Oct 22 2021
STATUS
approved