OFFSET
0,3
COMMENTS
This sequence is interesting because of the spike at the 2nd term.
The next similar spike occurs at a(59)=181733.
EXAMPLE
Recamán's sequence {b(m)} begins with 0, 1, 3, 6, 2, 7, 13,...
b(1-1)-1 = 0-1 = -1, so a(1) = 1.
b(5-1)-5 = 2-5 = -3, so a(3) = 5.
PROG
(Python)
def a(n):
a = [0]
for i in range(1, n):
a+=[-1]
countA = 1
seq = [0]
m = 1
while(countA < n):
x = seq[m-1]-m
if(x<0):
if(-x < n and a[-x]==-1):
a[-x] = m
countA+=1
seq+=[seq[m-1]+m]
else:
if(x not in seq):
seq+=[x]
else:
seq+=[seq[m-1]+m]
m+=1
return a #find all terms in range(0, n)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jens Askgaard, Jul 30 2024
STATUS
approved