# A338833 in Maple # f(n) computes first n terms of A338833 # If terms exceed a million, increase the constant 2^24 with(Bits); f := proc(M) local MMM,B,L,x,hit,smn,n,a,sw1,sw2,i,j; MMM:=100000; a:=Array(0..M,-1); a[0]:=0; a[1]:=1; a[2]:=3; a[3]:= 6; smn:=2; hit:=Array(0..MMM,-1); hit[0]:=0; hit[1]:=1; hit[3]:=2; hit[6]:=3; L:=6; B:=3; for n from 4 to M do sw1:=-1; for x from smn to MMM do if hit[x]=-1 and And(x,L)>0 and And(x,B)=0 and And(Not(L+2^24),x)>0 then sw1:=1; a[n]:=x; B:=L; L:=x; hit[x]:=n; break; fi; od: if sw1=-1 then lprint("error, no term found at ",n,L,B); lprint([seq(a[j],j=0..n)]); error("no term found"); fi; od: [seq(a[i],i=0..M-1)]; end; f(200);