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.

A174844 Primes that generate three other primes when 2, 6, and 8, respectively, are subtracted from each digit of their decimal representations.

This page as a plain text file.
%I A174844 #13 Nov 15 2022 12:24:38
%S A174844 9898898899,889898999999,889989889889,898888889989,989899998889,
%T A174844 999988988989,988898889999899,989998888989889,98888888989989899,
%U A174844 99999998998988999,888898989989989999,888998889889898899,889888889998888999,889888898999988989,889988888998998889
%N A174844 Primes that generate three other primes when 2, 6, and 8, respectively, are subtracted from each digit of their decimal representations.
%C A174844 Subsequence of A020472. The primes generated from the subtractions are in A020469, A020458, and A020449, respectively. Final digits are necessarily 9 (here), then 7, 3, and 1. Because leading 8's are permitted in the terms here, the primes generated by subtracting 8's may have fewer digits than the others.
%H A174844 Robert Israel, <a href="/A174844/b174844.txt">Table of n, a(n) for n = 1..1188</a>
%e A174844 9898898899 is prime and so are 7676676677, 3232232233, and 1010010011, so it is a term. Although 9349, 9349-2222=7127, 9349-6666=2683, and 9349-8888=461 are four primes, 9349 is not a term as subtracting 6 or 8 from the digits 3 and 4 is not possible (no "borrowing" is permitted).
%p A174844 Res:= NULL: count:= 0:
%p A174844 for d from 2 while count < 100 do
%p A174844   v:= (10^d-1)/9;
%p A174844   for m from 1 to d do
%p A174844     if m mod 3 <> 0 and 2*d+m mod 3 <> 0 then
%p A174844       for S in combinat:-choose([$1..(d-2)],m-1) do
%p A174844         q:= 1+add(10^i,i=S);
%p A174844         if andmap(isprime, [q, 2*v+q, 6*v+q, 8*v+q]) then
%p A174844            count:= count+1; Res:= Res, 8*v+q;
%p A174844         fi
%p A174844       od;
%p A174844     fi
%p A174844   od;
%p A174844 od:
%p A174844 sort([Res]); # _Robert Israel_, Nov 14 2022
%t A174844 okQ[n_]:=Module[{idn=IntegerDigits[n]},And@@PrimeQ[FromDigits/@ {idn-2, idn-6, idn-8}]]; Select[Flatten[Table[Select[FromDigits/@ Tuples[ {8,9},n], PrimeQ],{n,18}]],okQ] (* _Harvey P. Dale_, Jul 27 2011 *)
%o A174844 (PARI) {/* Program based on that of M. F. Hasler in A020472. */
%o A174844 for(nd=1, 20, p=vector(nd, i, 10^(nd-i))~; r=(10^nd-1)/9;
%o A174844 forvec(v=vector(nd, i, [8+(i==nd), 9]), q=v*p; isprime(q) &&
%o A174844 isprime(q-2*r ) && isprime(q-6*r ) && isprime(q-8*r ) && print1(q", ")))}
%o A174844 (Python)
%o A174844 from sympy import isprime
%o A174844 from itertools import count, islice, product
%o A174844 def agen(): # generator of terms
%o A174844     for d in count(2):
%o A174844         subs = list(map(int, ["2"*d, "6"*d, "8"*d]))
%o A174844         for first in product("89", repeat=d-1):
%o A174844             t = int("".join(first) + "9")
%o A174844             if isprime(t) and all(isprime(t-s) for s in subs): yield t
%o A174844 print(list(islice(agen(), 15))) # _Michael S. Branicky_, Nov 15 2022
%Y A174844 Cf. A020472, A020469, A020458, A020449.
%K A174844 base,nonn
%O A174844 1,1
%A A174844 _Rick L. Shepherd_, Mar 30 2010