login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(n) = A005132(2*n) + A005132(2*n+1).
2

%I #31 Sep 16 2022 02:10:49

%S 1,9,9,33,33,33,33,33,33,105,105,59,59,59,59,59,125,191,191,117,117,

%T 117,117,117,117,117,117,117,117,117,117,117,117,381,381,381,381,381,

%U 227,227,227,227,227,227,227,227,227,227,227,227,429,631,631,631,631,191,417,873,873

%N a(n) = A005132(2*n) + A005132(2*n+1).

%H Michel Marcus, <a href="/A356839/b356839.txt">Table of n, a(n) for n = 0..9999</a>

%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>.

%t r[0] = 0; r[n_] := r[n] = If[(d = r[n - 1] - n) >= 0 && FreeQ[Array[r, n, 0], d], d, r[n - 1] + n]; a[n_] := r[2*n] + r[2*n + 1]; Array[a, 100, 0] (* _Amiram Eldar_, Sep 02 2022 *)

%o (PARI) recaman(N)={ my(s, t, v=vector(N)); for(n=1, N, s=bitor(s, 1<<t += if( t<=n || bittest(s, t-n), n, -n)); v[n]=t); concat(0, v);} \\ adapted from A005132

%o lista(nn) = my(v=recaman(2*nn+2)); vector(nn, k, v[2*k] + v[2*k-1]); \\ _Michel Marcus_, Sep 02 2022

%o (Python)

%o from itertools import count, islice

%o def A356839_gen(): # generator of terms

%o b, aset = 0, set()

%o for n in count(1):

%o aset.add(b)

%o a, b = b, c if (c:=b-n)>=0 and c not in aset else b+n

%o if n&1:

%o yield a+b

%o A356839_list = list(islice(A356839_gen(),70)) # _Chai Wah Wu_, Sep 15 2022

%Y Cf. A005132.

%K nonn

%O 0,2

%A _Paul Curtz_, Aug 31 2022