|
|
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).
|
|
3
|
|
|
|
OFFSET
|
1,1
|
|
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.
The number of occurrences of the digit 1 or 2 is congruent to 2 (mod 3). - Robert Israel, Mar 07 2016
|
|
LINKS
|
The Prime Puzzles and Problems Connection, Puzzle 822
|
|
EXAMPLE
|
1301 belongs to this sequence because 1303, 1301, 1901 and 3301 are all prime.
|
|
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:
|
|
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 *)
|
|
PROG
|
(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"
(Python)
from sympy import isprime
from itertools import product
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 is_prime(int(''.join(d2))):
break
else:
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,hard,more
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|