login
A356870
a(n) = (A005132(2*n-1) + A005132(2*n))/4.
1
1, 2, 5, 8, 8, 8, 8, 8, 17, 26, 26, 15, 15, 15, 15, 15, 48, 48, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 62, 95, 95, 95, 95, 95, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 158, 158, 158, 158, 103, 48, 161, 218, 218, 99, 99, 99, 99, 99, 35, 35, 168, 100, 100, 100
OFFSET
1,2
LINKS
MATHEMATICA
r[-1] = 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 - 1] + r[2*n])/4; Array[a, 100] (* Amiram Eldar, Sep 02 2022 *)
PROG
(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); v; } \\ adapted from A005132
lista(nn) = my(v=recaman(2*nn+2)); vector(nn, k, v[2*k-1] + v[2*k])/4; \\ Michel Marcus, Sep 13 2022
(Python)
from itertools import count, islice
def A356870_gen(): # generator of terms
b, aset = 0, set()
for n in count(1):
aset.add(b)
a, b = b, c if (c:=b-n)>=0 and c not in aset else b+n
if not n&1:
yield a+b>>2
A356870_list = list(islice(A356870_gen(), 30)) # Chai Wah Wu, Sep 15 2022
CROSSREFS
Sequence in context: A019824 A284868 A019772 * A351391 A046825 A374442
KEYWORD
nonn,look
AUTHOR
Paul Curtz, Sep 02 2022
EXTENSIONS
New name, data and offset from Michel Marcus, Sep 13 2022
STATUS
approved