OFFSET
1,4
LINKS
Gavin Lupo, Table of n, a(n) for n = 1..10000
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
KEYWORD
AUTHOR
Gavin Lupo, Apr 05 2022
STATUS
approved