OFFSET
1,2
COMMENTS
Can be constructed as follows: place of terms of (2^k+1,2^k+2,...,2^k) are the reflection from (2,3,4,...,2^k,1). [Comment not clear to me - N. J. A. Sloane]
If n == 0 mod 4, then n is in the sequence. If n == 2 mod 4, then n is not in the sequence. The number 2n - 1 is in the sequence if and only if n is in the sequence. For n > 1, n is in the sequence if and only if A038189(n-1) = 1. - N. Sato, Feb 12 2013
The set B contains all numbers 2^(k-1)+1 = (2^k+2)/2 (half of the "forbidden sums"), (2, 3, 5, 9, 17, 33, 65,...) = 1/2 * (4, 6, 10, 18, 34, 66, 130, 258,...). - M. F. Hasler, Feb 12 2013
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..1000
Kevin Ryde, Iterations of the Dragon Curve, see index TurnRight, with a(n) = TurnRight(n-2) + 1 for n>=2.
FORMULA
a(1) = 1; and for n > 1: a(n) = A091067(n-1)+1. - Antti Karttunen, Feb 20 2015, based on N. Sato's Feb 12 2013 comment above.
MAPLE
a:= proc(n) option remember; local k, t;
if n=1 then 1
else for k from 1+a(n-1) do t:= k-1;
while irem(t, 2, 'r')=0 do t:=r od;
if irem(t, 4)=3 then return k fi
od
fi
end:
seq(a(n), n=1..100); # Alois P. Heinz, Feb 12 2013
MATHEMATICA
a[n_] := a[n] = Module[{k, t, q, r}, If[n == 1, 1, For[k = 1+a[n-1], True, k++, t = k-1; While[{q, r} = QuotientRemainder[t, 2]; r == 0, t = q]; If[Mod[t, 4] == 3, Return[k]]]]]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 30 2017, after Alois P. Heinz *)
PROG
(PARI) a(n) = if(n=2*n-2, my(t=1); forstep(i=logint(n, 2), 0, -1, if(bittest(n, i)==t, n++; t=!t))); n+1; \\ Kevin Ryde, Mar 21 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Sen-Peng Eu, May 01 2001
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), May 10 2001
STATUS
approved