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).

Original entry on oeis.org

11, 311, 1301, 10133, 1030031
Offset: 1

Views

Author

Arkadiusz Wesolowski, Aug 08 2011

Keywords

Comments

These numbers do not occur in A050249 (weakly associated primes).
p cannot contain digits 1 and 2 at the same time due to divisibility by 3.
No more terms < 10^9. [Reinhard Zumkeller, Aug 11 2011]
No more terms < 10^14. - Arkadiusz Wesolowski, Feb 08 2012
No more terms < 10^18. - Giovanni Resta, Feb 23 2013
No more terms < 10^22. - Jan van Delden, Mar 06 2016
The number of occurrences of the digit 1 or 2 is congruent to 2 (mod 3). - Robert Israel, Mar 07 2016

Examples

			1301 belongs to this sequence because 1303, 1301, 1901 and 3301 are all prime.
		

Crossrefs

Programs

  • Haskell
    import Data.List (inits, tails)
    a193890 n = a193890_list !! (n-1)
    a193890_list = filter f a107715_list where
       f n = (all ((== 1) . a010051) $
                   zipWith (\ins (t:tns) -> read $ (ins ++ x3 t ++ tns))
                           (init $ inits $ show n) (init $ tails $ show n))
           where x3 '0' = "0"
                 x3 '1' = "3"
                 x3 '2' = "6"
                 x3 '3' = "9"
    -- Reinhard Zumkeller, Aug 11 2011
    
  • Maple
    S:= NULL:
    for x from 2 to 3^10 do
       L:= convert(x, base, 3):
       if numboccur(1,L) mod 3 <> 2 then next fi;
       L1:= subs(2=3,L);
       L2:= subs(1=2,L1);
       for LL in [L1,L2] do
         y:= add(LL[i]*10^(i-1), i=1..nops(L1));
         if isprime(y) then
          good:= true;
          for j from 1 to nops(LL) do
             yp:= y + 2*LL[j]*10^(j-1);
             if not isprime(yp) then
                good:= false;
                break
             fi
          od:
          if good then S:= S, y fi;
         fi;
       od
    od:
    sort([S]); # Robert Israel, Mar 07 2016
  • Mathematica
    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 *)
  • Python
    from sympy import isprime
    from itertools import product
    A193890_list = []
    for l in range(1,10):
        for d in product('0123',repeat=l):
            p = int(''.join(d))
            if d[0] != '0' and d[-1] in ('1','3') and isprime(p):
                for i in range(len(d)):
                    d2 = list(d)
                    d2[i] = str(3*int(d[i]))
                    if not isprime(int(''.join(d2))):
                        break
                else:
                     A193890_list.append(p) # Chai Wah Wu, Aug 13 2015