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.

A348561 Primes where every other digit is 9 starting with the rightmost digit, and no other digit is 9.

This page as a plain text file.
%I A348561 #19 Sep 08 2022 08:46:26
%S A348561 19,29,59,79,89,919,929,1949,1979,2909,2939,2969,3919,3929,3989,4909,
%T A348561 4919,4969,5939,6949,6959,7919,7949,8929,8969,90989,91909,91939,91969,
%U A348561 92959,93949,93979,94949,95929,95959,95989,96959,96979,96989,97919,98909,98929
%N A348561 Primes where every other digit is 9 starting with the rightmost digit, and no other digit is 9.
%H A348561 Michael S. Branicky, <a href="/A348561/b348561.txt">Table of n, a(n) for n = 1..10000</a>
%t A348561 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=={9}&&FreeQ[Flatten@Last@t,9])&] (* _Giorgos Kalogeropoulos_, Oct 22 2021 *)
%t A348561 id[n_]:=IntegerDigits[n];il[n_]:=IntegerLength[n];eQ[n_]:=EvenQ[il[n]]&&AllTrue[Flatten[Position[id[n],9]],EvenQ]&&Length[Cases[id[n],9]]==il[n]/2;oQ[n_]:=OddQ[il[n]]&&
%t A348561 AllTrue[Flatten[Position[id[n],9]],OddQ]&&Length[Cases[id[n],9]]==(il[n]+1)/2;
%t A348561 Select[Prime[Range[10^5]],oQ[#]||eQ[#]&] (* _Ivan N. Ianakiev_, Oct 24 2021 *)
%o A348561 (Magma) f9:=func<n|forall{i:i in [1..#Intseq(n) by 2]| Intseq(n)[i] eq 9}>;  fc:=func<n|  forall{i:i in [2..#Intseq(n) by 2]| Intseq(n)[i] ne 9}>; [p:p in PrimesUpTo(100000)|f9(p) and fc(p)]; // _Marius A. Burtea_, Oct 22 2021
%o A348561 (Python)
%o A348561 from sympy import primerange as primes
%o A348561 def ok(p):
%o A348561     s = str(p)
%o A348561     if not all(s[i] == '9' for i in range(-1, -len(s)-1, -2)): return False
%o A348561     return all(s[i] != '9' for i in range(-2, -len(s)-1, -2))
%o A348561 print(list(filter(ok, primes(1, 98930)))) # _Michael S. Branicky_, Oct 22 2021
%o A348561 (Python) # faster version for generating large initial segments of sequence
%o A348561 from sympy import isprime
%o A348561 from itertools import product
%o A348561 def eo9(maxdigits): # generator for every other digit is 7, no other 7's
%o A348561     yield 9
%o A348561     for d in range(2, maxdigits+1):
%o A348561         if d%2 == 0:
%o A348561             for f in "12345678":
%o A348561                 f9 = f + "9"
%o A348561                 for p in product("012345678", repeat=(d-1)//2):
%o A348561                     yield int(f9 + "".join(p[i]+"9" for i in range(len(p))))
%o A348561         else:
%o A348561             for p in product("012345678", repeat=(d-1)//2):
%o A348561                 yield int("9" + "".join(p[i]+"9" for i in range(len(p))))
%o A348561 print(list(filter(isprime, eo9(5)))) # _Michael S. Branicky_, Oct 22 2021
%Y A348561 Cf. A000040, A348558, A348559, A348560.
%K A348561 nonn,base
%O A348561 1,1
%A A348561 _Lars Blomberg_, Oct 22 2021