OFFSET
1,4
COMMENTS
Insertion here means that the new 1-bit must come somewhere right of the most significant 1-bit. - Antti Karttunen, Dec 15 2017
LINKS
FORMULA
EXAMPLE
n = 25->'11001': A000040(16)=53->'110[1]01', therefore a(25)=1;
a(255)=a(2^8-1)=5, as 2^(8+5)-1=8191 is a Mersenne prime and 2^(8+i)-1 is not prime for i<5.
PROG
(PARI)
insert1bit(n, pos) = (((n>>pos)<<(1+pos))+(1<<pos)+bitand(n, (2^pos)-1));
binwidth(n) = { my(k=0); while(n, n>>=1; k++); k; };
A091991(n) = { if(1==n, return(1)); if(isprime(n), return(0)); if(!(n%2), return(1+A091991(1+n+n))); my(k, nexttries, prevtries = Set([n]), w = binwidth(n)-1); for(b=1, oo, nexttries = Set([]); for(t=1, length(prevtries), h = prevtries[t]; for(i=1, w, if(isprime(k=insert1bit(h, i)), return(b), nexttries = setunion(Set([k]), nexttries)))); prevtries = nexttries; w++); };
\\ Antti Karttunen, Dec 15 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Mar 17 2004
STATUS
approved