OFFSET
0,6
COMMENTS
For n > 0 and after A005132(n-1) the algorithm of Recamán's sequence first explores if A005132(n-1) - n = A334951(n) is a valid number to be its n-th term. If A334951(n) is nonnegative and not already in Recamán's sequence then it is accepted, so A005132(n) = A334951(n), otherwise A334951(n) is rejected and A005132(n) = A005132(n-1) + n, not A334951(n). This sequence lists the pairs [A334951(n), A005132(n)], with a(0) = 0.
EXAMPLE
Illustration of initial terms:
23
22 _
21 _ |
20 _ | | |
_ | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
13 | | | | | | |
_ | | 12 | | | | |
| | | |_ _ | | 11 | | |
| | | | | |_ _ | | 10 |
| | | 12 | | | | |_ _ |
| | | | | 11 | | | |
7 | | | | | | | 10 | |
6 _ | | | | | | | | |
_ | | | |_| | | | | | |
| | | | | | | | | | |
3 | | | | | 6 | | | | | |
_ | | 2 | | | |_| | | | |
1 | | | |_ _ | | | | | | |
0 _ | | | | | |_| 3 | | | |
_ _ | | | |_| 2 | | |_| | |
|_| |_| | | 1 | |
0 0 | | 0 | |
-1 -1 |_| |_|
.
-3 -3
.
In the above diagram the numbers that are written below the path are the terms of A334951 (the candidates for A005132). The numbers that are written above the path are the terms of Recamán's sequence A005132. The length of the n-th vertical-line-segment equals the absolute value of A334952(n).
For n = 4, after A005132(4-1) = 6 the algorithm of Recamán's sequence first explores if A334951(4) = 6 - 4 = 2 is a valid number to be its 4th term. We can see that 2 is nonnegative and not already in Recamán's sequence, then it is accepted, so A005132(4) = A334951(4) = 2.
CROSSREFS
KEYWORD
sign
AUTHOR
Omar E. Pol, May 17 2020
STATUS
approved