A103144 Decimal primes whose decimal representation in hex is also prime.
2, 3, 5, 7, 11, 13, 17, 29, 43, 47, 53, 59, 61, 67, 71, 83, 89, 97, 101, 107, 137, 139, 151, 167, 191, 199, 223, 233, 239, 241, 251, 257, 269, 277, 281, 283, 293, 313, 337, 347, 359, 373, 397, 409, 419, 443, 449, 463, 503, 509, 557, 577, 593, 599, 607, 617, 641
Offset: 1
Examples
11 is prime, Hex(11) = 17 is prime, hence 11 is in the sequence.
Links
- Andreas Boe, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A089971.
Programs
-
MATLAB
a = primes(300000); j = 0; for i = 1:19000 b = dec2hex(a(i)); c = num2str(b); d = str2num(c); if d < 2^32 if isprime(d) j = j + 1; e(j) = d; end; end; end;
-
Mathematica
Select[Prime@ Range@ 120, PrimeQ@ FromDigits[IntegerDigits@ #, 16] &] (* Michael De Vlieger, Nov 05 2018 *)
-
PARI
isok(p) = isprime(p) && isprime(fromdigits(digits(p), 16)); \\ Michel Marcus, Nov 05 2018
-
Python
from sympy import isprime def ok(n): return isprime(n) and isprime(int(str(n), 16)) print([k for k in range(642) if ok(k)]) # Michael S. Branicky, Dec 04 2022