Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #10 Oct 09 2015 18:00:52
%S 1,2,1,3,4,2,1,5,6,3,7,8,4,2,1,9,10,5,11,12,6,3,13,14,7,15,16,8,4,2,1,
%T 17,18,9,19,20,10,5,21,22,11,23,24,12,6,3,25,26,13,27,28,14,7,29,30,
%U 15,31,32,16,8,4,2,1,33,34,17,35,36,18,9,37,38,19,39,40,20,10,5,41,42,21
%N Triangle read by rows: n-th row starts with n and continues with half the previous value as long as that is even.
%C A fractal sequence, generated by the rule a(n) is a new maximum when a(n-1) is odd and a repetition of an earlier value when a(n-1) is even.
%H Alois P. Heinz, <a href="/A123390/b123390.txt">Rows n = 1..10000, flattened</a>
%F a(1) = 1, for n > 1, if a(n-1) is even, a(n) = a(n-1)/2, otherwise a(n) = (max_{k<n} a(k)) + 1.
%F Ordinal transform of A082850.
%e Triangle starts
%e 1;
%e 2, 1;
%e 3;
%e 4, 2, 1;
%e 5;
%e 6, 3;
%e 7;
%e 8, 4, 2, 1;
%e 9;
%e 10, 5;
%e 11;
%e 12, 6, 3;
%e 13;
%p T:= proc(n) local m,l; m:=n; l:= m;
%p while irem(m, 2, 'm')=0 do l:=l,m od: l
%p end:
%p seq(T(n), n=1..40); # _Alois P. Heinz_, Oct 09 2015
%t Flatten[Function[n, NestWhile[Append[#, Last[#]/2] &, {n}, EvenQ[Last[#]] &]][#] & /@ Range[20]] (* _Birkas Gyorgy_, Apr 13 2011 *)
%Y Row lengths are A001511. Cf. A120385.
%K nonn,tabf
%O 1,2
%A _Franklin T. Adams-Watters_, Oct 13 2006