%I #52 Apr 03 2023 10:36:12
%S 11,311,1301,10133,1030031
%N 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 These numbers do not occur in A050249 (weakly associated primes).
%C p cannot contain digits 1 and 2 at the same time due to divisibility by 3.
%C No more terms < 10^9. [_Reinhard Zumkeller_, Aug 11 2011]
%C No more terms < 10^14. - _Arkadiusz Wesolowski_, Feb 08 2012
%C No more terms < 10^18. - _Giovanni Resta_, Feb 23 2013
%C No more terms < 10^22. - _Jan van Delden_, Mar 06 2016
%C The number of occurrences of the digit 1 or 2 is congruent to 2 (mod 3). - _Robert Israel_, Mar 07 2016
%H G. L. Honaker, Jr. and Chris Caldwell, <a href="https://t5k.org/curios/cpage/23926.html">Prime Curios! 1030031</a>
%H The Prime Puzzles and Problems Connection, <a href="http://www.primepuzzles.net/puzzles/puzz_822.htm">Puzzle 822</a>
%e 1301 belongs to this sequence because 1303, 1301, 1901 and 3301 are all prime.
%p S:= NULL:
%p for x from 2 to 3^10 do
%p L:= convert(x, base, 3):
%p if numboccur(1,L) mod 3 <> 2 then next fi;
%p L1:= subs(2=3,L);
%p L2:= subs(1=2,L1);
%p for LL in [L1,L2] do
%p y:= add(LL[i]*10^(i-1), i=1..nops(L1));
%p if isprime(y) then
%p good:= true;
%p for j from 1 to nops(LL) do
%p yp:= y + 2*LL[j]*10^(j-1);
%p if not isprime(yp) then
%p good:= false;
%p break
%p fi
%p od:
%p if good then S:= S, y fi;
%p fi;
%p od
%p od:
%p sort([S]); # _Robert Israel_, Mar 07 2016
%t 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 (Haskell)
%o import Data.List (inits, tails)
%o a193890 n = a193890_list !! (n-1)
%o a193890_list = filter f a107715_list where
%o f n = (all ((== 1) . a010051) $
%o zipWith (\ins (t:tns) -> read $ (ins ++ x3 t ++ tns))
%o (init $ inits $ show n) (init $ tails $ show n))
%o where x3 '0' = "0"
%o x3 '1' = "3"
%o x3 '2' = "6"
%o x3 '3' = "9"
%o -- _Reinhard Zumkeller_, Aug 11 2011
%o (Python)
%o from sympy import isprime
%o from itertools import product
%o A193890_list = []
%o for l in range(1,10):
%o for d in product('0123',repeat=l):
%o p = int(''.join(d))
%o if d[0] != '0' and d[-1] in ('1','3') and isprime(p):
%o for i in range(len(d)):
%o d2 = list(d)
%o d2[i] = str(3*int(d[i]))
%o if not is_prime(int(''.join(d2))):
%o break
%o else:
%o A193890_list.append(p) # _Chai Wah Wu_, Aug 13 2015
%Y Cf. A010051, A007090, A107715, A050249.
%K nonn,base,hard,more
%O 1,1
%A _Arkadiusz Wesolowski_, Aug 08 2011
|