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.

A193890 Primes p such that replacing any single decimal digit d with 3*d produces another prime (obviously p can contain only digits 0, 1, 2 or 3).

This page as a plain text file.
%I A193890 #56 Jul 05 2025 11:24:53
%S A193890 11,311,1301,10133,1030031
%N A193890 Primes p such that replacing any single decimal digit d with 3*d produces another prime (obviously p can contain only digits 0, 1, 2 or 3).
%C A193890 These numbers do not occur in A050249 (weakly associated primes).
%C A193890 p cannot contain digits 1 and 2 at the same time due to divisibility by 3.
%C A193890 No more terms < 10^9. [_Reinhard Zumkeller_, Aug 11 2011]
%C A193890 No more terms < 10^14. - _Arkadiusz Wesolowski_, Feb 08 2012
%C A193890 No more terms < 10^18. - _Giovanni Resta_, Feb 23 2013
%C A193890 No more terms < 10^22. - _Jan van Delden_, Mar 06 2016
%C A193890 The number of occurrences of the digit 1 or 2 is congruent to 2 (mod 3). - _Robert Israel_, Mar 07 2016
%H A193890 G. L. Honaker, Jr. and Chris Caldwell, <a href="https://t5k.org/curios/cpage/23926.html">Prime Curios! 1030031</a>
%H A193890 The Prime Puzzles and Problems Connection, <a href="https://www.primepuzzles.net/puzzles/puzz_822.htm">Puzzle 822</a>
%e A193890 1301 belongs to this sequence because 1303, 1301, 1901 and 3301 are all prime.
%p A193890 S:= NULL:
%p A193890 for x from 2 to 3^10 do
%p A193890    L:= convert(x, base, 3):
%p A193890    if numboccur(1,L) mod 3 <> 2 then next fi;
%p A193890    L1:= subs(2=3,L);
%p A193890    L2:= subs(1=2,L1);
%p A193890    for LL in [L1,L2] do
%p A193890      y:= add(LL[i]*10^(i-1), i=1..nops(L1));
%p A193890      if isprime(y) then
%p A193890       good:= true;
%p A193890       for j from 1 to nops(LL) do
%p A193890          yp:= y + 2*LL[j]*10^(j-1);
%p A193890          if not isprime(yp) then
%p A193890             good:= false;
%p A193890             break
%p A193890          fi
%p A193890       od:
%p A193890       if good then S:= S, y fi;
%p A193890      fi;
%p A193890    od
%p A193890 od:
%p A193890 sort([S]); # _Robert Israel_, Mar 07 2016
%t A193890 Select[Select[Prime@ Range[10^6], AllTrue[IntegerDigits@ #, MemberQ[{0, 1, 2, 3}, #] &] &], Function[k, AllTrue[Map[FromDigits, Map[MapAt[3 # &, IntegerDigits@ k, #] &, Range@ IntegerLength@ k]], PrimeQ]]] (* _Michael De Vlieger_, Mar 06 2016, Version 10 *)
%o A193890 (Haskell)
%o A193890 import Data.List (inits, tails)
%o A193890 a193890 n = a193890_list !! (n-1)
%o A193890 a193890_list = filter f a107715_list where
%o A193890    f n = (all ((== 1) . a010051) $
%o A193890                zipWith (\ins (t:tns) -> read $ (ins ++ x3 t ++ tns))
%o A193890                        (init $ inits $ show n) (init $ tails $ show n))
%o A193890        where x3 '0' = "0"
%o A193890              x3 '1' = "3"
%o A193890              x3 '2' = "6"
%o A193890              x3 '3' = "9"
%o A193890 -- _Reinhard Zumkeller_, Aug 11 2011
%o A193890 (Python)
%o A193890 from sympy import isprime
%o A193890 from itertools import product
%o A193890 A193890_list = []
%o A193890 for l in range(1,10):
%o A193890     for d in product('0123',repeat=l):
%o A193890         p = int(''.join(d))
%o A193890         if d[0] != '0' and d[-1] in ('1','3') and isprime(p):
%o A193890             for i in range(len(d)):
%o A193890                 d2 = list(d)
%o A193890                 d2[i] = str(3*int(d[i]))
%o A193890                 if not isprime(int(''.join(d2))):
%o A193890                     break
%o A193890             else:
%o A193890                  A193890_list.append(p) # _Chai Wah Wu_, Aug 13 2015
%Y A193890 Cf. A010051, A007090, A107715, A050249.
%K A193890 nonn,base,hard,more
%O A193890 1,1
%A A193890 _Arkadiusz Wesolowski_, Aug 08 2011