OFFSET
1,1
COMMENTS
Also, numbers with a prime number of bits 1 (cf. A001348), interleaved with bits 0. Or: odd numbers with alternating binary digits and a prime Hamming weight A000120, cf. A052294. - M. F. Hasler, Oct 16 2018
FORMULA
EXAMPLE
For n = 1, the first prime number is 2, so a(1) = (4^2-1)/3 = (16-1)/3 = 15/3 = 5;
for n = 2, prime(2) = 3, so a(2) = (4^3-1)/3 = (64-1)/3 = 63/3 = 21;
for n = 5, prime(5) = 11, so a(5) = (4^(11)-1)/3 = (4194304-1)/3 = 4194303/3 = 1398101.
MATHEMATICA
a[n_]:=(4^Prime[n] - 1)/3; Array[a, 50] (* Stefano Spezia, Oct 16 2018 *)
PROG
(Java) public static int a(int n){ int p = 1; while(n > 0){ p++; if(!new String(new char[p]).matches("(..+?)\\1+|.?")){ n--; } } return ((int) Math.pow(4, p)-1)/3; }
(PARI) a(n) = (4^prime(n) - 1)/3; \\ Michel Marcus, Mar 27 2018
(Magma) [(4^NthPrime(n) - 1)/3: n in [1..20]]; // Vincenzo Librandi, Oct 17 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
André Dalwigk, Mar 26 2018
STATUS
approved