OFFSET
0,3
LINKS
T. D. Noe, Table of n, a(n) for n=0..1642 (taking a(1355) from A064227)
Nick Hobson, Python program for this sequence
C. L. Mallows, Plot (jpeg) of first 10000 terms of A005132
C. L. Mallows, Plot (postscript) of first 10000 terms of A005132
N. J. A. Sloane, My favorite integer sequences, in Sequences and their Applications (Proceedings of SETA '98).
N. J. A. Sloane, FORTRAN program for A005132, A057167, A064227, A064228
MAPLE
w := array(1..10000); for j from 1 to 100 do l := 0; for k from 1 to nops(a) do if a[k] = j then l := k; exit; fi; od: w[j] := l; od: s := [seq(w[j], j=1..100)]; # where a is an array formed from sequence A005132
MATHEMATICA
PROG
(PARI) first(n) = my(a=vector(n), r=[0]); while(#Set(a)<n, my(i=#r, j=r[i]-i, k=j+(j<1 || setsearch(Set(r), j))*2*i); r=concat(r, [k]); if(k<n && !a[k+1], a[k+1]=i)); a \\ Iain Fox, Jul 11 2022
(Python)
from itertools import count, islice
def agen(): # generator of terms
an, A005132set, inv, y = 0, {0}, {0: 0}, 0
for n in count(1):
t = an - n
an = t if t >= 0 and t not in A005132set else an + n
A005132set.add(an)
inv[an] = n
while y in inv: yield inv[y]; y += 1
print(list(islice(agen(), 61))) # Michael S. Branicky, Jul 12 2022
CROSSREFS
KEYWORD
AUTHOR
N. J. A. Sloane, Sep 14 2000
EXTENSIONS
a(0)=0 added and escape clause value changed to -1 by N. J. A. Sloane, May 01 2020
STATUS
approved