%I #31 Mar 22 2021 05:50:13
%S 1,4,7,8,12,13,15,16,20,23,24,25,28,29,31,32,36,39,40,44,45,47,48,49,
%T 52,55,56,57,60,61,63,64,68,71,72,76,77,79,80,84,87,88,89,92,93,95,96,
%U 97,100,103,104,108,109,111,112,113,116,119,120,121,124,125,127,128
%N Separate the natural numbers into disjoint sets A, B with 1 in A, such that the sum of any 2 distinct elements of the same set never equals 2^k + 2. Sequence gives elements of set A.
%C 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_]
%C 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
%C 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
%H Alois P. Heinz, <a href="/A060833/b060833.txt">Table of n, a(n) for n = 1..1000</a>
%H Kevin Ryde, <a href="http://user42.tuxfamily.org/dragon/index.html">Iterations of the Dragon Curve</a>, see index TurnRight, with a(n) = TurnRight(n-2) + 1 for n>=2.
%F 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.
%p a:= proc(n) option remember; local k, t;
%p if n=1 then 1
%p else for k from 1+a(n-1) do t:= k-1;
%p while irem(t, 2, 'r')=0 do t:=r od;
%p if irem(t, 4)=3 then return k fi
%p od
%p fi
%p end:
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Feb 12 2013
%t 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_ *)
%o (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
%Y Essentially one more than A091067.
%Y First differences: A106836.
%Y A082410(a(n)) = 0.
%K easy,nonn
%O 1,2
%A _Sen-Peng Eu_, May 01 2001
%E More terms from Larry Reeves (larryr(AT)acm.org), May 10 2001