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.

A348559 Primes where every other digit is 3 starting with the rightmost digit, and no other digit is 3.

This page as a plain text file.
%I A348559 #15 Sep 08 2022 08:46:26
%S A348559 3,13,23,43,53,73,83,313,353,373,383,1303,1373,2383,2393,4363,4373,
%T A348559 5303,5323,5393,6323,6343,6353,6373,7393,8353,8363,9323,9343,30313,
%U A348559 30323,31393,32303,32323,32353,32363,34303,34313,35323,35353,35363,35393,36313,36343
%N A348559 Primes where every other digit is 3 starting with the rightmost digit, and no other digit is 3.
%H A348559 Michael S. Branicky, <a href="/A348559/b348559.txt">Table of n, a(n) for n = 1..10000</a>
%t A348559 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=={3}&&FreeQ[Flatten@Last@t,3])&] (* _Giorgos Kalogeropoulos_, Oct 22 2021 *)
%o A348559 (Magma) f3:=func<n|forall{i:i in [1..#Intseq(n) by 2]| Intseq(n)[i] eq 3}>;  fc:=func<n|  forall{i:i in [2..#Intseq(n) by 2]| Intseq(n)[i] ne 3}>; [p:p in PrimesUpTo(40000)|f3(p) and fc(p)]; // _Marius A. Burtea_, Oct 22 2021
%o A348559 (Python)
%o A348559 from sympy import primerange as primes
%o A348559 def ok(p):
%o A348559     s = str(p)
%o A348559     if not all(s[i] == '3' for i in range(-1, -len(s)-1, -2)): return False
%o A348559     return all(s[i] != '3' for i in range(-2, -len(s)-1, -2))
%o A348559 print(list(filter(ok, primes(1, 36344)))) # _Michael S. Branicky_, Oct 22 2021
%o A348559 (Python) # faster version for generating large initial segments of sequence
%o A348559 from sympy import isprime
%o A348559 from itertools import product
%o A348559 def eo3(maxdigits): # generator for every other digit is 3, no other 3's
%o A348559     yield 3
%o A348559     for d in range(2, maxdigits+1):
%o A348559         if d%2 == 0:
%o A348559             for f in "12456789":
%o A348559                 f3 = f + "3"
%o A348559                 for p in product("012456789", repeat=(d-1)//2):
%o A348559                     yield int(f3 + "".join(p[i]+"3" for i in range(len(p))))
%o A348559         else:
%o A348559             for p in product("012456789", repeat=(d-1)//2):
%o A348559                 yield int("3" + "".join(p[i]+"3" for i in range(len(p))))
%o A348559 print(list(filter(isprime, eo3(5)))) # _Michael S. Branicky_, Oct 22 2021
%Y A348559 Cf. A000040, A348558, A348560, A348561.
%K A348559 nonn,base
%O A348559 1,1
%A A348559 _Lars Blomberg_, Oct 22 2021