OFFSET
1,1
COMMENTS
The n-th prime is a term iff A100714(n) = 3. - Joseph Biberstine (jrbibers(AT)indiana.edu), Dec 11 2004
A019434 \{3} is a subsequence, since the base-2 representation of a Fermat prime 2^(2^k)+1 > 3 is a single 1, followed by a block of 2^k-1 0's, followed by a last single 1. - Bernard Schott, Mar 07 2023
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Run-Length Encoding.
EXAMPLE
1987 = 11111000011_2, which is a block of 5 1's, followed by a block of 4 0's, followed by a block of 2 1's, so 1987 is a term.
a(3)=17 is a term because it is the 3rd prime whose binary representation splits into exactly three runs: 17_10 = 10001_2 splits into {{1}, {0,0,0}, {1}}.
MATHEMATICA
Select[Table[Prime[k], {k, 1, 500}], Length[Split[IntegerDigits[ #, 2]]] == 3 &]
PROG
(PARI) decomp(s)=if(s%2==0, return(1), ); k=1; while(k==1, k=s%2; s=floor(s/2)); if(s==0, return(1), ); while(k==0, k=s%2; s=floor(s/2)); while(k==1, k=s%2; s=floor(s/2)); return(s)
forprime(i=1, 2000, if(decomp(i)==0, print1(i, ", ")))
(Python)
from sympy import isprime
from itertools import count, islice
def agen(): yield from filter(isprime, ((1<<k)-(1<<j)+(1<<i)-1 for k in count(1) for j in range(k-1, 1, -1) for i in range(1, j)))
print(list(islice(agen(), 52))) # Michael S. Branicky, Feb 25 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Randy L. Ekl, May 03 2003
STATUS
approved