login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

%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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 5 20:07 EDT 2024. Contains 374954 sequences. (Running on oeis4.)