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 #38 Dec 09 2023 01:44:19
%S 0,1,1,2,1,3,4,2,1,3,7,9,10,5,6,3,13,15,16,8,4,2,1,3,7,22,11,14,7,9,
%T 13,28,14,7,18,9,20,10,5,12,6,3,8,4,2,1,3,7,13,22,11,23,30,15,20,10,5,
%U 28,14,7,37,40,20,10,5,12,6,3,8,4,2,1,3,7,13,53
%N a(1) = 0; a(2) = 1; thereafter a(n) = a(n-1)/2 if a(n-1) is even, otherwise a(n) = a(n-1) + a((n-1)-a(n-1)).
%H Gavin Lupo, <a href="/A352840/b352840.txt">Table of n, a(n) for n = 1..10000</a>
%e a(1)=0.
%e a(2)=1.
%e 1 is odd, so a(3) = a(2) + a(2-a(2)) = a(2) + a(2-1) = a(2) + a(1) = 1 + 0 = 1.
%e 1 is odd, so a(4) = a(3) + a(3-a(3)) = a(3) + a(3-1) = a(3) + a(2) = 1 + 1 = 2.
%e 2 is even, so a(5) = a(4)/2 = 2/2 = 1.
%e Continuing, we get
%e n a(n)
%e - ----
%e 1 0
%e 2 1
%e 3 1 + a(1) 1 + 0 = 1
%e 4 1 + a(2) 1 + 1 = 2
%e 5 a(4) / 2 2 / 2 = 1
%e 6 1 + a(4) 1 + 2 = 3
%e 7 3 + a(3) 3 + 1 = 4
%e 8 a(7) / 2 4 / 2 = 2
%e 9 a(8) / 2 2 / 2 = 1
%e 10 1 + a(8) 1 + 2 = 3
%e 11 3 + a(7) 3 + 4 = 7
%e 12 7 + a(4) 7 + 2 = 9
%o (Python)
%o result = [0, 1]
%o iterations = 100
%o for i in range(1, iterations):
%o if result[i]%2 == 0:
%o result.append(result[i] // 2)
%o else:
%o result.append(result[i] + result[i - result[i]])
%o print(result, end='', sep=' ')
%o (MATLAB)
%o result = [0 1];
%o iterations = 100;
%o for i = 2:iterations
%o if mod(result(i), 2) == 0
%o result(i+1) = int32(result(i)/2);
%o else
%o result(i+1) = (result(i) + result(i - result(i)));
%o end
%o end
%Y Cf. A350129.
%K nonn,look,easy
%O 1,4
%A _Gavin Lupo_, Apr 05 2022