login

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”).

A352840
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)).
1
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, 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, 28, 14, 7, 37, 40, 20, 10, 5, 12, 6, 3, 8, 4, 2, 1, 3, 7, 13, 53
OFFSET
1,4
EXAMPLE
a(1)=0.
a(2)=1.
1 is odd, so a(3) = a(2) + a(2-a(2)) = a(2) + a(2-1) = a(2) + a(1) = 1 + 0 = 1.
1 is odd, so a(4) = a(3) + a(3-a(3)) = a(3) + a(3-1) = a(3) + a(2) = 1 + 1 = 2.
2 is even, so a(5) = a(4)/2 = 2/2 = 1.
Continuing, we get
n a(n)
- ----
1 0
2 1
3 1 + a(1) 1 + 0 = 1
4 1 + a(2) 1 + 1 = 2
5 a(4) / 2 2 / 2 = 1
6 1 + a(4) 1 + 2 = 3
7 3 + a(3) 3 + 1 = 4
8 a(7) / 2 4 / 2 = 2
9 a(8) / 2 2 / 2 = 1
10 1 + a(8) 1 + 2 = 3
11 3 + a(7) 3 + 4 = 7
12 7 + a(4) 7 + 2 = 9
PROG
(Python)
result = [0, 1]
iterations = 100
for i in range(1, iterations):
if result[i]%2 == 0:
result.append(result[i] // 2)
else:
result.append(result[i] + result[i - result[i]])
print(result, end='', sep=' ')
(MATLAB)
result = [0 1];
iterations = 100;
for i = 2:iterations
if mod(result(i), 2) == 0
result(i+1) = int32(result(i)/2);
else
result(i+1) = (result(i) + result(i - result(i)));
end
end
CROSSREFS
Cf. A350129.
Sequence in context: A229287 A286539 A004741 * A133923 A347296 A341231
KEYWORD
nonn,look,easy
AUTHOR
Gavin Lupo, Apr 05 2022
STATUS
approved