login
A387660
a(0) = 0; thereafter a(n) = a(n-1) - n if a(n-1) > 2*n and not already in the sequence, otherwise a(n) = a(n-1) + n.
2
0, 1, 3, 6, 10, 15, 9, 16, 24, 33, 23, 12, 24, 37, 51, 36, 20, 37, 19, 38, 58, 79, 57, 34, 58, 83, 109, 82, 54, 83, 53, 84, 52, 85, 119, 154, 118, 81, 43, 82, 42, 83, 125, 168, 124, 169, 123, 76, 124, 75, 125, 74, 126, 73, 127, 72, 128, 71, 129, 70, 130
OFFSET
0,3
LINKS
EXAMPLE
a(4) = 10 because subtracting 4 from the previous term (6) would give 2, which is smaller than 4, so add 4 to 6 to get 10.
a(6) = 9 because subtracting 6 from the previous term (15) gives 9, which is bigger than 6, and has not appeared before.
a(9) = 33 because subtracting 9 from the previous term (24) gives 15, which is bigger than 9, but has appeared before, so add 9 to 24 to get 33.
MATHEMATICA
s={0}; Do[If [s[[-1]]>2n&&!MemberQ[s, s[[-1]]-n], AppendTo[s, s[[-1]]-n], AppendTo[s, s[[-1]]+n]], {n, 60}]; s (* James C. McMahon, Sep 21 2025 *)
CROSSREFS
Cf. A005132.
Sequence in context: A194101 A105333 A126234 * A259604 A130484 A074374
KEYWORD
nonn
AUTHOR
Kelvin Voskuijl, Sep 05 2025
STATUS
approved