cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A348558 Primes where every other digit is 1 starting with the rightmost digit, and no other digit is 1.

This page as a plain text file.
%I A348558 #21 May 28 2023 14:39:58
%S A348558 31,41,61,71,101,131,151,181,191,2131,2141,2161,3121,3181,3191,5101,
%T A348558 5171,6101,6121,6131,6151,7121,7151,8101,8161,8171,8191,9151,9161,
%U A348558 9181,10141,10151,10181,12101,12161,13121,13151,13171,15101,15121,15131,15161,16141
%N A348558 Primes where every other digit is 1 starting with the rightmost digit, and no other digit is 1.
%H A348558 Michael S. Branicky, <a href="/A348558/b348558.txt">Table of n, a(n) for n = 1..10000</a>
%t A348558 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 *)
%t A348558 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 *)
%o A348558 (Python)
%o A348558 from sympy import primerange as primes
%o A348558 def ok(p):
%o A348558     s = str(p)
%o A348558     if not all(s[i] == '1' for i in range(-1, -len(s)-1, -2)): return False
%o A348558     return all(s[i] != '1' for i in range(-2, -len(s)-1, -2))
%o A348558 print(list(filter(ok, primes(1, 16142)))) # _Michael S. Branicky_, Oct 22 2021
%o A348558 (Python) # faster version for generating large initial segments of sequence
%o A348558 from sympy import isprime
%o A348558 from itertools import product
%o A348558 def eo1(maxdigits): # generator for every other digit is 1, no other 1's
%o A348558     yield 1
%o A348558     for d in range(2, maxdigits+1):
%o A348558         if d%2 == 0:
%o A348558             for f in "23456789":
%o A348558                 f1 = f + "1"
%o A348558                 for p in product("023456789", repeat=(d-1)//2):
%o A348558                     yield int(f1 + "".join(p[i]+"1" for i in range(len(p))))
%o A348558         else:
%o A348558             for p in product("023456789", repeat=(d-1)//2):
%o A348558                 yield int("1" + "".join(p[i]+"1" for i in range(len(p))))
%o A348558 print(list(filter(isprime, eo1(5)))) # _Michael S. Branicky_, Oct 22 2021
%o A348558 (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
%Y A348558 Cf. A000040, A348559, A348560, A348561.
%K A348558 nonn,base
%O A348558 1,1
%A A348558 _Lars Blomberg_, Oct 22 2021