login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Numbers k that are the representation of primes in base 3 and in base 4.
2

%I #52 Dec 15 2021 16:35:26

%S 2,1121,2021,2111,10121,10211,11201,12011,12121,12211,21101,21211,

%T 22111,101021,101111,110021,110111,110221,111211,112001,121001,121021,

%U 122011,200111,201101,210011,211021,211111,222221,1000211,1002011,1010111,1011121,1012201,1021001

%N Numbers k that are the representation of primes in base 3 and in base 4.

%C Except for a(1) = 2, which is the only even prime, all terms end with 1.

%C The corresponding sequences of primes are A235473 (for base 3) and A235467 (for base 4) (see examples).

%C As 1381 = 1220011_3 = 111211_4, prime 1381 occurs twice and is the next such prime after 2 (see example), which has a representation in base 3 and a representation in base 4 that are both terms of this sequence.

%H Chai Wah Wu, <a href="/A340290/b340290.txt">Table of n, a(n) for n = 1..10000</a>

%e a(1) = 2 and 2_3 = 2_4 = 2_10.

%e a(2) = 1121 because 1121_3 = 43_10 and 1121_4 = 89_10 are primes.

%e a(3) = 2021 because 2021_3 = 61_10 and 2021_4 = 137_10 are primes.

%t f[n_] := Module[{d = IntegerDigits[n, 3]}, If[PrimeQ[FromDigits[d, 4]], FromDigits[d, 10], 0]]; seq = {}; Do[If[PrimeQ[n], m = f[n]; If[m > 0, AppendTo[seq, m]]], {n, 2, 1000}]; seq (* _Amiram Eldar_, Jan 03 2021 *)

%t FromDigits[#]&/@Select[Tuples[{0,1,2},7],PrimeQ[FromDigits[#,4]] && PrimeQ[ FromDigits[ #,3]]&] (* _Harvey P. Dale_, Dec 15 2021 *)

%o (PARI) f(n, b) = fromdigits(digits(n, b));

%o my(vp=primes(700)); setintersect(apply(x->f(x,3), vp), apply(x->f(x,4), vp)) \\ _Michel Marcus_, Jan 04 2021

%o (PARI) forprime(p=2, 10^3, my(t=digits(p,3)); if( isprime( fromdigits(t,4)), print1(fromdigits(t,10),", "))) \\ _Joerg Arndt_, Jan 04 2021

%o (Python)

%o from sympy import prime, isprime

%o from sympy.ntheory.factor_ import digits

%o A340290_list = [int(s) for s in (''.join(str(d) for d in digits(prime(i),3)[1:]) for i in range(1,1000)) if isprime(int(s,4))] # _Chai Wah Wu_, Jan 09 2021

%Y Intersection of A001363 and A004678.

%Y Cf. A089981 (bases 3 and 10).

%Y Cf. A235467, A235473.

%K nonn,base

%O 1,1

%A _Bernard Schott_, Jan 03 2021

%E More terms from _Amiram Eldar_, Jan 03 2021